|
bar chart with grouping |
Posted by at on Apr-01-2019 17:19 |
|
Hi Peter, what's the best way to generate the attached chart in Chartdirector PHP?
Thanks.
|
Re: bar chart with grouping |
Posted by Peter Kwan on Apr-02-2019 04:04 |
|
Hi at,
You can consider to create it as a simple stacked bar chart. You can leave some bars as empty by using NoValue as the data, and set their corrresponding x-axis label as empty by using "~" as the label. This empty position becomes the gap between bars.
I notice the gap seems to have a different background color from the bar positions. This can be achieved by adding a vertical zone (see XYChart.addZone) at the gap positions.
For the texts at the top, I would add it using custom textboxes (BaseChart.addText), configured to have the proper size and position (see Box.setSize).
Regards
Peter Kwan |
Re: bar chart with grouping |
Posted by at on Apr-12-2019 17:04 |
|
Thanks Peter, but is there an efficient way of setting the texts at the top of the bars without using Layer.getImageCoor() since it would require creating the image first? |
Re: bar chart with grouping |
Posted by Peter Kwan on Apr-12-2019 18:52 |
|
Hi at,
Yes, just use BaseChart.addText to add the text at the top as mentioned in my previous message.
The y-coordinates is the top of the plot area, which your code already knows. For the x-coordinate, if you have 50 x-axis positions, and the plot area width is 500 pixels, then each position must occupy 500 / 50 = 10 pixels. So the x-coordinates can also be determined without drawing the image.
Hope this can help.
Regards
Peter Kwan |
|