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

Message ListMessage List     Post MessagePost Message

  Pyramidchart WITH own defined gradient possible?
Posted by Mats H?gglund on May-04-2015 16:46
Attachments:
Hi, we would like to have the same gradient effect on our Pyramidchart that we do on
barcharts. A gradient from color x to color y. Is that possible?

I?m attaching the wanted barchart gradient nd pyramid as it looks now.

This is our current Pyramid code:

if(showSummarize) {
mySampleColors.add(0xe31818);
mySampleColors.add(0xdca000);
mySampleColors.add(0x367fb2);
mySampleColors.add(0x577748);
PyramidChart pyramidChart = new PyramidChart(1700, 700);
pyramidChart.setBackground(0xffffff);
pyramidChart.setFunnelSize(320, 320, 200, 500);
pyramidChart.setViewAngle(5, 5);
pyramidChart.setRightLabel("{label}\\n({value}%)", "OpenSans-Regular.ttf", 20);
pyramidChart.setData(RAMUtil.toDoubleArray(mySampleValues),
RAMUtil.toStringArray(myBarLabels));
pyramidChart.addExtraField(RAMUtil.toStringArray(myLegendLabels));
pyramidChart.setColors2(Chart.DataColor, RAMUtil.toIntArray(mySampleColors));
pyramidChart.setLayerGap(0.02);
LegendBox legendBox = pyramidChart.addLegend(1200, 600,false, "OpenSans-
Regular.ttf", 20);
legendBox.setText("{field0}");
legendBox.setAlignment(Chart.BottomCenter);
legendBox.setCols(1);
pyramidChart.layoutLegend();
legendBox.setBackground(Chart.Transparent, Chart.Transparent);
chart1URL = pyramidChart.makeSession(request, "chartPanoramaSummarize");



Any help is appreciated, Mats
summarize.png
panorama.png

  Re: Pyramidchart WITH own defined gradient possible?
Posted by Peter Kwan on May-05-2015 04:11
Hi Matts,

Yes. You can use linear gradient colors for the funnel segments. It is like:

double[] myData = RAMUtil.toDoubleArray(mySampleValues);
double total = 0;
for (int i = 0; i < myData.length; ++i)
   total += myData[i];

int[]  myColors = new int[myData.length];
double ratio = 0;
for (int i = 0; i < myData.Length; ++i)
{
     int topY = 300 - 500 / 2 + (int)(500 * ratio);
     ratio += myData[i] / total;
     int bottomY = 300 - 500 / 2 + (int)(500 * ratio);
     myColors[i] = pyramidChart.linearGradientColor(0, topY, 0, bottomY, gradientTopColor[i],
gradientBottomColor[i]);
}

pyramidChart.setColors2(Chart.DataColor, myColors);

Hope this can help.

Regards
Peter Kwan