|
How to change the image(small icon) to text in a financial chart? |
Posted by dudu on Jan-17-2016 02:39 |
|
Hi,
I have a chart like the attached picture.
For performance issue, I want to change the icons to CHAR like
"ABBCCDDDDCCBA" or "AABBCCCCCCCBA".
Now, I draw a gray dot icon if value under 40. I want to change it to show a "A".
I draw a green dot icon if value under 30. I want to change it to show a "B".
I draw a transparent dot icon if value under 20. I want to change it to show a "C".
I draw a smile icon if the value under 10. I want to change it to show a "D"
Would you mind show me the code?
Thanks in advance.
|
Re: How to change the image(small icon) to text in a financial chart? |
Posted by Peter Kwan on Jan-19-2016 02:28 |
|
Hi dudu,
To do this, you may use scatter layers to draw icons like in your current code, with each
layer handling one type of icon. The icons can be 1-pixel transparent squares so they are
not visible. Then you can attach text labels to the icons using Layer.setDataLabelFormat
and Layer.setDataLabelStyle. For example, in C++:
Layer *layer = c->addScatterLayer(.......); // a transparent one point icon
layer->setDataLabelFormat("A"); //use A as the label
layer->setDataLabelStyle("arial.ttf", 8, 0x000000)->setAlignment(Chart::Top);
Hope this can help.
Regards
Peter Kwan |
Re: How to change the image(small icon) to text in a financial chart? |
Posted by dudu on Jan-19-2016 15:14 |
|
Hi peter,
Thank you for your solution.
Unfotunately, your solution can draw graph for me.
But the performance is even worse.
The reason why I don't want to darw the chart using icon is the performance issue.
In my case, I have to use 10 scatterlayers to draw the icons.
And in your solution. Each layer has to draw a icon and draw text.
So the performance is very poor than before.
I want to know are there any other method I can draw the chart using series of text only.
I can create a serise of text in advance. All I want is better performance. I don't need the color of text.(if with color is better but if the performance is not accetable then color is not a necessity)
Thanks in advance. |
Re: How to change the image(small icon) to text in a financial chart? |
Posted by Peter Kwan on Jan-19-2016 21:42 |
|
Hi dudu,
Draw text is usually slower than drawing a rectangle of the same size. If you look at the
text careful, you can see the shape of text is more complicated than a rectangle.
For your case, if you have less than a hundred symbols, adding a scatter layer with simple
shapes usually takes only a very small amount of time comparing to drawing other parts
of the chart itself.
If your chart also has image maps or tooltips, I think the effect of these user interaction
features can use more time than the drawing the symbols itself, as each symbol adds an
additional "hot spot" region on the screen. (A hot spot is like a small button on the screen.
It can take some time if you have thousands of buttons on the screen.)
Would you mind to clarify how many symbols are there on your chart and whether you are
using image maps (pop-up tooltips) or not? What is the performance you are seeing? If
you are using less than a thousand symbols, I would suspect the performance with or
without the scatter layers would be quite similar. (You may perpare all the data as usual,
but just comment out the "addScatterLayer" line to test how much is the performance
difference.)
If you need further help, is it possible to inform me of the code that draws the chart (at
least the part that draws the scatter layers)? If you cannot post the code in a public forum,
you may email me at pkwan@advsofteng.net.
Regards
Peter Kwan |
|