Algorithm for resize multi selected elements on the canvas - graphics

I have shapes with integer coordinates of width and height. They can be selected and stretched separately, I want to add the function of stretching a group of selected shapes. For example, as in the Figma editor or in VS Studio on a visual canvas, when we select a set of shapes and stretch them and they stretch proportionally with integer coordinates of width and height. Can you tell me how it works? For example, I have a list of 5 shapes with a width and height of 10px, indents from each other in 1px, I have selected them and pull them along the X axis in the positive direction by 8 pixels, which algorithm do I need to use? Here is an example of how it looks in VS when stretching buttons on the canvas.
https://i.stack.imgur.com/mYOAf.gif

Related

chartist.js: stroke-linecap is extending the stroke beyond the length of the shape in Bar charts

I'm using chartist.js library in our project. I've a requirement where in I have to display rounded corners for bar charts. I tried by applying stroke-linecap:round !important;.But the stroke-linecap CSS property is extending the stroke beyond the length of the shape in bar charts.
But I want the rounded corner painted in the range of the length of the shape.
How can i achieve this? Please help.

Text in Ellipses JavaFX

I created a custom venn chart for two sets an their intersection in JavaFX.
Now I want to show the number of elements in this sets like in the following picture:
The sets are ellipses and I used masks to give the intersection a different color.
Now I want to show the number with size and position related to the available space so that the numbers are always inside the according area.
The width for the text element is easy to calculate, but I don't know how to get available height for the text elements.
Maybe it could be helpful to have the pixels of the ellipses as path, but I have no idea to how I can get this.
Does anyone know how to implement that?
Edit:
I developed an algorithm to find the size of a rectangle, which fits in the required areas of the ellipses. The text are scaled to the size of the rectangle and it works, but now I have another problem.
I need to center the scaled text in the rectangle an I used a StackPane for that. But I can't position the StackPane in the chart parent. If I set the layoutX and layoutY the bounds in parent are different.
For example: stackPane with text = sp;
sp.setLayoutY(122.1662320906945);
The Result for getBoundsInParent().getMinY() is 97.16622924804688;
How can I set the StackPane position, if I use it in a chart class as chart children?

Can an Enum be used to provide two values?

For drawing filled shapes like Rectangle, Eclipse need two values width and height (converted from int to float).
There's an enum,
Public enum Sizes : int
{
One=5,
Two=10,
Five=10,
Seven=12,
Ten=15,
}
In terms of drawing a Square of One, should be of width and height of 5. Which is straight forward. However when drawing Oval Shapes and Rectangular shapes above one value isn't sufficient.
Is there a way I could define another float value? So when compared for Ten, it can provide 15 for Width and 10 for Height...
Or does it mean, there should be two enums, one for Width and one for Height?
EDIT to provide more background info:
There's an UI which allows users to create certain shapes.
User inputs are: Shape Type (Line, Rectangle, Eclipse), Points, Size (but this size doesn't exactly reflect the size of the shape. e.g. 10 is a capacity. Capacity 10 must draw 15px Width and 10px height Rectangle/Eclipse).
Line doesn't take Size into account as it is drawn using the Points input. The rest of the shapes do take Size into account. So this is where I need to check the Size(capacity) parameter and issue the correct Width and Height to be drawn.

Excel chart grid size and multiple colors (no VBA)

I would like to ask for your help on two major problems I have with an Excel (2003) chart:
1) I would like to create a chart which has got 25 grids (5 on the x axis and 5 on the y axis). The number of grids must not change, i.e. data should have no impact on the size, length and number of grids (several different worksheets are used as input to the chart). How can I create such a chart without having different grid lenghts depending on data?
2) I need a chart which has 25 grids, with each grid being colored differently, e.g. for example 3 grids in the upper right corner are red, 3 grids in lower left corner are green, inbetween all grids are colored white. I have read some articles on creating charts with a quadrant background, i.e. 4 grids, each having a different color. But I would like to know how I can create multi colored background for 25 grids?
Many thanks in advance!!
Regards,
Since you don't want to use VBA, there are a number of hand steps that are needed to create the grid chart you are looking for. For the most part, these steps can be taken in any order.
Enter what will be the horizontal column labels in a 1 x 5 cell range in your worksheet.
In the 5 x 5 cell range immediately below, enter the value 1 in each cell.
Selecting the 6 x 5 cell range, insert a 100% Stacked Column chart into the worksheet. You will now have a chart with of bars with five horizontal bands, each of a different color.
Delete the legend.
Select one of the bands to format and set its Gap Width to "No Gap."
Insert a chart title and horizontal and vertical axis titles, if any.
Select each band (data series) and set its fill color to solid fill white and its border color to solid line black.
Select the chart area and set its height and width to identical values.
Lock the chart area's aspect ratio.
Select and set the fill color of each data point (grid cell) that you want in a contrasting color.
(I am unaware of any way to dynamically set the colors of the grid cells based upon different data values, other than via VBA.)
If you want to change the font size of the labels of one of the axes, be sure to set the other axis to the same size to preserve the square grid layout.
Set the major tick mark type of the vertical axis to None, and the font color of the vertical axis labels to white.
At this point, you may want to shift the plot area to the left so that there is more white space between the right borders of the plot area and the chart area.
Select the chart area and then insert a text box over the vertical axis label area.
Enter into the text box the vertical axis labels that you want to show, with a blank line between each label, and with the font size and color of your choice.
Move the text box vertically so that, by eye, the first of labels in the text box is by eye aligned vertically with the center of the top row of the grid.
Select the blank line between the first two labels in the text box and change the line's font size so that, again by eye, the second label is aligned vertically with the center of the second grid row. Continue with the three remaining labels.
If you want finer control of the alignment of the labels, insert a second line between the each pair of labels and set the font size for the second lines in a smaller font than the first lines.
This text box is the only element of the chart that will not automatically resize if you change the size of the chart.
Other than any minor tweaking of the font sizes or alignment of the chart title and the axis labels, the chart is done:

SVG - resize tspan to fill all available space

I have tspan element with some text in it. I specified some font-size for it as well. In addition I have parent's box size, i.e. width and height. So now I'd like my text to fit the box with the specified width and height.
One of the options I have is manually calculate string width and height (but it became more complicated in case of different fonts and browsers).
So is there any other way in SVG to resize tspan to necessary sizes? Please note that I want text font size to be changed properly, i.e. so text will be displayed in max font size and any single char from it will be visible.
Well, I've came up with the following solution - have absolutely positioned div element outside of visible area. Apply all fonts and other-related styles (except font size) from tspan to that div, put text into the div. Next try different sizes (you can use binary search for better performance) and measure div size. Once max font size found - apply it along with the text to tspan.

Resources