The texts in the center are the results of four LabelItem's:
LabelItem item1 = new LabelItem();
item1.setHtml("<html>Communication</htlm>");
Style style = new Style();
style.setLeft("25px");
style.setTop("40px");
style.setColor("#999a99");
style.setFontFamily("verdana");
style.setFontSize("11px");
item1.setStyle(style);
LabelItem item2 = new LabelItem();
item2.setHtml("<html>success</htlm>");
Style style2 = new Style();
style2.setLeft("45px");
style2.setTop("54px");
style2.setColor("#999a99");
style2.setFontFamily("verdana");
style2.setFontSize("11px");
item2.setStyle(style2);
LabelItem item3 = new LabelItem();
item3.setHtml("<html>77</htlm>");
Style style3 = new Style();
style3.setLeft("47px");
style3.setTop("84px");
style3.setColor("#000000");
style3.setFontFamily("verdana");
style3.setFontSize("30px");
item3.setStyle(style3);
LabelItem item4 = new LabelItem();
item4.setHtml("<html>%</htlm>");
Style style4 = new Style();
style4.setLeft("84px");
style4.setTop("70px");
style4.setColor("#000000");
style4.setFontFamily("verdana");
style4.setFontSize("11px");
item4.setStyle(style4);
chart.setLabelItems(item1, item2, item3, item4);
But those label items are positioned by using the Style methods setTop() and setLeft() using hardcoded numbers.
Now, whenever those texts change (eg. other language, other percentage with only 1 or 3 digits) how do I keep those LabelItems centered?
Can I use some setting to keep those label items centered?
If not, can I at least determine how long (in pixels) a word (eg. "Communication") will be in that font and font size?
To be able to calculate the parameter I need to pass to setLeft() that is.
Another question I have about the same pie chart:
when the percentage value changes, I perform this:
myChart.removeAllSeries(false);
Series series = createSeries().setPoints(createPoints());
myChart.addSeries(series);
The chart then shows the new percentage, but in completely other/random colors than the ones I set previously.
adding
myChart.setColors(mainColor, secondColor);
after
myChart.removeAllSeries(false);
doesn't help.
Why are my initial colors no more used? How to apply them again?
Also, I have to update the LabelItem showing the percentage value.
How do I do that?
Apparently, calling setLabelItems() again with the updated LabelItems doesn't seem to work...
Thanks in advance.
Last edit: zzynx 2012-09-26
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi(gh),
I'm using a PieChart to draw some kind of percentage gauge:
http://s17.postimage.org/shbx1bufj/SC_Screenshot_12_09_25_001.png
The texts in the center are the results of four LabelItem's:
But those label items are positioned by using the Style methods setTop() and setLeft() using hardcoded numbers.
Now, whenever those texts change (eg. other language, other percentage with only 1 or 3 digits) how do I keep those LabelItems centered?
Can I use some setting to keep those label items centered?
If not, can I at least determine how long (in pixels) a word (eg. "Communication") will be in that font and font size?
To be able to calculate the parameter I need to pass to setLeft() that is.
Another question I have about the same pie chart:
when the percentage value changes, I perform this:
with
The chart then shows the new percentage, but in completely other/random colors than the ones I set previously.
adding
myChart.setColors(mainColor, secondColor);
after
myChart.removeAllSeries(false);
doesn't help.
Why are my initial colors no more used? How to apply them again?
Also, I have to update the LabelItem showing the percentage value.
How do I do that?
Apparently, calling setLabelItems() again with the updated LabelItems doesn't seem to work...
Thanks in advance.
Last edit: zzynx 2012-09-26