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

Message ListMessage List     Post MessagePost Message

  linearGradientColor
Posted by Stefan Ohlsson on Apr-22-2015 18:45
Attachments:
Hello!
First, thanks for a great product! We are happy paying customers.

We are trying to accomplish the attached image "correct.jpg", the attached code
generates "incorrect.jpg". We have a problem to set linearGradientColor with the correct
values (start and end of yAxis). Could you help us with this ?

double[] data = {25, 50, 100};
int[] startColor = {0xca0202, 0xca0202, 0xca0202};
int[] endColor = {0xf14747, 0xf14747, 0xf14747};
String[] labels = {"Mon", "Tue", "Wed"};
XYChart c = new XYChart(300, 220, 0xffffff, 0, 0);
c.setPlotArea(40, 40, 240, 150);
BarLayer layer = c.addBarLayer3(data);
c.xAxis().setLabels(labels);
c.layoutAxes();
for (int i = 0; i < data.length; ++i)
{
System.out.println(c.getYCoor(data[i]));
  int myBarColor = c.linearGradientColor(0, "What to insert here?",
   0, "What to insert here?", startColor[i], endColor[i], false);
  layer.getDataSet(i).setDataColor(myBarColor);
}
String chart1URL = c.makeSession(request, "chart1");

We also would like to have the graph .setLinearScale(0, 100, 20); but that seems to not
work when  using layoutAxes().

Appreciate any help.

Best regards

/Stefan Ohlsson
incorrect.png
correct.jpg

  Re: linearGradientColor
Posted by Peter Kwan on Apr-23-2015 02:09
Attachments:
Hi Stefan,

I have just tried your code with setLinearScale(0, 100, 20), and it seems to work
normally. My code is:

double[] data = {25, 50, 100};
int[] startColor = {0xca0202, 0xca0202, 0xca0202};
int[] endColor = {0xf14747, 0xf14747, 0xf14747};
String[] labels = {"Mon", "Tue", "Wed"};
XYChart c = new XYChart(300, 220, 0xffffff, 0, 0);
c.setPlotArea(40, 40, 240, 150);
BarLayer layer = c.addBarLayer3(data);
c.xAxis().setLabels(labels);
c.yAxis().setLinearScale(0, 100, 20);
c.layoutAxes();
for (int i = 0; i < data.length; ++i)
{
  int myBarColor = c.linearGradientColor(0, c.getYCoor(0),
   0, c.getYCoor(data[i]), startColor[i], endColor[i], false);
  layer.getDataSet(i).setDataColor(myBarColor);
}
String chart1URL = c.makeSession(request, "chart1");

Please let me know if the above is what you need.

Regards
Peter Kwan
test.png