ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Gradient Shading is not working for area chart in case color % drop to less than 50
Posted by Ankit Jain on Dec-15-2017 14:02
Attachments:
Hi Peter,

I am using gradient shading for area chart and this is working perfect when i have color%(Alpha transparency) range between 50 to 100%. But as soon as i reduce % below 50.Color disappear.
Please find below sample for 100% color and 49%.

The code is working fine when i use solid color in place of gradient for 0 to 100% range.

Please find below snapshot of code i am using.

              double dColorPercent = (double)(100 - m_iColorPercent)/CONST_100;
              int AlphaColor = (int)(255.0 * dColorPercent);

              int Val = color + (AlphaColor << 24);

Thanks,
Ankit
100%.jpg
49%.jpg

  Re: Gradient Shading is not working for area chart in case color % drop to less than 50
Posted by Peter Kwan on Dec-16-2017 02:26
Attachments:
Hi Ankit,

I have just tried your code, and it works correctly in my case. The code I used is as follows and I have attached the chart I got.

XYChart *c = new XYChart(250, 250);
c->setPlotArea(30, 20, 200, 200);

int m_iColorPercent = 25;
const int CONST_100 = 100;
int color = 0xff0000;
int color2 = 0x00ff00;

double dColorPercent = (double)(100 - m_iColorPercent) / CONST_100;
int AlphaColor = (int)(255.0 * dColorPercent);

int Val = color + (AlphaColor << 24);
int Val2 = color2 + (AlphaColor << 24);

int areaColor = c->linearGradientColor(c->getPlotArea()->getLeftX(), 0, c->getPlotArea()->getRightX(), 0, Val, Val2);
c->addAreaLayer(DoubleArray(data, sizeof(data)/sizeof(data[0])), areaColor);

c->makeChart("test.png");
delete c;


For your case, is it possible to create a complete example with real data values that can be run and can reproduce the problem? May be you can just try to modify my test code to try to reproduce the problem so I can test and troubleshoot it.

Regards
Peter Kwan
test.png

  Re: Gradient Shading is not working for area chart in case color % drop to less than 50
Posted by Ankit Jain on Dec-20-2017 15:23
Hi Peter,

I think I am able to figure out where the problem is. What I was doing is I was adding  the layers first with some arbitrary color and after that I was adding gradient color to it.

I was using below code for gradient shading
m_Layer.getDataSet(0).setDataColor(c.linearGradientColor(c.getPlotArea().getRightX(), 0, 0, 0,
pLayer.getStartingColor(),pLayer.getEndingColor()));

your code does the reverse.
I was wondering does it make any difference.

Or there is problem while achieving the same with m_Layer.getDataSet(0).setDataColor.

Kindly share you thoughts on this so that I will take care of such things in future.

Appreciate your help and will keep you posted once I will be done with full functionality.

Thanks
Ankit

  Re: Gradient Shading is not working for area chart in case color % drop to less than 50
Posted by Peter Kwan on Dec-21-2017 01:41
Hi Ankit,

If the color works normally when the transparency is over 50%, but not when it is below 50%, then it cannot be caused by adding the color afterwards. I suspect may be there is an issue in pLayer.getStartingColor() and /or pLayer.getEndingColor(), in that it does not return the correct color.

To test if the above is the case, please hard coded the color.

m_Layer.getDataSet(0).setDataColor(c.linearGradientColor(c.getPlotArea().getRightX(), 0, 0, 0, 0xaaff0000, 0xaa00ff00);

If the hard coded color works, then it means the color returned from pLayer.getStartingColor() / pLayer.getEndingColor() is different from the hard coded color.

Hope this can help.

Regards
Peter Kwan

  Re: Gradient Shading is not working for area chart in case color % drop to less than 50
Posted by Ankit Jain on Dec-22-2017 13:12
Hi Peter,

I found bug in my code. This was not getting executed in case of -ve color values.

Thanks for your help!

Thanks
Ankit