|
Altering the drawarea at runtime |
Posted by Danieldeparis on May-04-2019 19:35 |
|
Hi Peter,
Over the last couple yeary we have started to routinely impose "star-based ratings" images onto our CD-based charting output.
Up to now, we simply embedded pictures either as "png-based routines" or using CD standard symbols. They include stars. Which is great. Producing these "integer-based" star ratings material is quite easy indeed ![:-)](icons/icon7.gif)
Thanks for the great API!
We now have the request to impose "decimal-ratings" onto the output - see the attachments.
We could possibly use GDI calls - we are on Winxx - or alternative libraries for this. But there is possibly a simpler way to do this right within the CD toolbox.
Any simple way to deliver the output required ? An ability to run this o arbitrary colored png resources would be even greater.
Kind regards, Daniel
|
Re: Altering the drawarea at runtime |
Posted by Danieldeparis on May-06-2019 14:00 |
|
Hi Peter,
As a supplement to my question, which may or not be clear enough, I am considering an alternative solution that would basically work this way:
1- provide two distinct images ahead of the process - say png resources, one for the full value (say a black or golden star) and one for the null value (ie some sort of blank star),
2- (pre-)load the two of them as drawarea "objects" at runtime,
3- build the "decimal-valued star image" drawarea at runtime from the two resources using the merge functionality upon each plot building,
4- either feed this "decimal-valued star image" either directly as drawarea or as png when this is required - for example as https://www.advsofteng.com/gallery_scatter.html when used on scatter plots
https://www.advsofteng.com/gallery_scatter.html
Does that seem a reasonable way to provide this "half-colored" images?
Regards, Daniel |
Re: Altering the drawarea at runtime / sorry for "typo" |
Posted by Danieldeparis on May-06-2019 15:39 |
|
Hi Peter,
As a supplement to my question, which may or not be clear enough, I am considering an alternative solution that would basically work this way:
1- provide two distinct images ahead of the process - say png resources, one for the full value (say a black or golden star) and one for the null value (ie some sort of blank star),
2- (pre-)load the two of them as drawarea "objects" at runtime,
3- build the "decimal-valued star image" drawarea at runtime from the two resources using the merge functionality upon each plot building,
4- either feed this "decimal-valued star image" either directly as drawarea or as png when this is required when used as custom images on scatter plots, for example in the "battle Robots" sample in:
https://www.advsofteng.com/gallery_scatter.html
Does that seem a reasonable way to provide this "half-colored" images?
Regards, Daniel |
Re: Altering the drawarea at runtime / sorry for "typo" |
Posted by Peter Kwan on May-06-2019 17:00 |
|
Hi Danieldeparis,
It happened ChartDirector has a built-in star symbol. See:
https://www.advsofteng.com/doc/cdnet.htm#builtinsymbols.htm
If you can accept using the built-in star symbol instead of the image, one easier method is to simply create a scatter chart using the built-in star symbol. You can use one scatter layer per symbol. For the symbol color, you can use a "x-zone color", which is a color that changes based on the x-coordinate. See:
https://www.advsofteng.com/doc/cdnet.htm#xzonecolor.htm
Suppose you configure the x-axis to be x = 0 to 3 (eg. using Axis.setLinearScale), and the three symbols are centered at x = 0.5, 1.5, 2.5, and the symbol size is around 0.9 x-axis unit. (I leave a gap of 0.1 x-axis unit between symbols.) So to fill the symbol at 30%, it is like (in C#):
//
// Consider the symbol centered at x = 1.5, y = 0.5
//
int symbolColor = c.xZoneColor(1.5 + 0.9 * (0.3 - 0.5), 0x555555, 0xeeeeee);
// Add the symbol using the above color
c.addScatterLayer(new double[] { 1.5 }, new double[] { 0.5 }, "", symbolColor, 9, symbolColor, symbolColor).setSymbolScale(new double[] { 0.9 }, Chart.XAxisScale);
By putting the above code in a loop, it should be able to generate all the stars.
If you prefer to use images, there is a similar method. Instead of using 0x555555, 0xeeeeee as the colors, you can use the two images two create two pattern colors (BaseChart.patternColor2), and use them to paint a square symbol.
Hope this can help.
Regards
Peter Kwan |
Re: Altering the drawarea at runtime / sorry for "typo" |
Posted by Peter Kwan on May-06-2019 17:03 |
|
Hi Danieldeparis,
The addScatterLayer above has a mistake. I forgot about the shape. It should be:
c.addScatterLayer(new double[] { 1.5 }, new double[] { 0.5 }, "", Chart.StarShape(5), 9, symbolColor, symbolColor).setSymbolScale(new double[] { 0.9 }, Chart.XAxisScale);
Regards
Peter Kwan |
Re: Altering the drawarea at runtime / sorry for "typo" |
Posted by Danieldeparis on May-08-2019 00:11 |
|
Hi Peter,
Peter Kwan wrote:
Hope this can help.
Thanks for your very detailed feedback on my questions. I'll come back later on this thread once we have settled for a solution.
We will certainly use distinct solutions for CD symbols such as stars and arbitrary png content. There is anyway clearly plenty of alternatives for such a question.
Of course we aim at simple code and, whenever possible, a way to avoid temporary file resources. The speed is clearly always there with CD. And that's great.
Regards for the great support here on the forum:-)
Daniel |
|