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

Message ListMessage List     Post MessagePost Message

  multibar chart... question
Posted by sogware on Feb-23-2012 11:14
Attachments:
multibar chart... question

i can't speak engilsh (korean)
so... paint image...

now problem... is...

label 2, 3, 4 -> bar position...

not center...

help me...
mc.jpg

  Re: multibar chart... question
Posted by Peter Kwan on Feb-24-2012 01:27
Hi sogware,

There is a sample code called "Overlapping Bar Chart" that looks like the chart you need. You may look for "Overlapping Bar Chart" from the ChartDirector documentation index.

If you just want to have a red bar in "Label_2" position, you can set the blue and orange data series to 0 or NoValue in that position.

Or do you mean you want the red bar in the "Label_2" position to be center aligned to "Label_2"? If this this is the case, you may need to use multiple bar layers, each for one group of bars. In C#:

//your data
double[] redData = {10, 20, 0, 0};
double[] blueData = {15, 0, 24, 0};
double[] orangeData = {20, 0, 20, 30};

for (int i = 0; i < redData.Length; ++i) {

    BarLayer b = c.addBarLayer2(Chart.Side);
    int barWidth = c.getPlotArea().getWidth() * 4 / (redData.Length * 5);
    b.setBarWidth(barWidth, barWidth / 2);
    b.setBorderColor(Chart.Transparent);

    double[] buffer = new double[redData.Length];

    buffer[i] = redData[i];
    if (buffer[i] != 0)
         b.addDataSet(buffer, 0xff3333);

    buffer[i] = blueData[i];
    if (buffer[i] != 0)
         b.addDataSet(buffer, 0x8888ff);

    buffer[i] = orangeData[i];
    if (buffer[i] != 0)
         b.addDataSet(buffer, 0xffcc66);
}

If you would like me to translate the above code to another programming language, please let me know which programming language you are using.

Hope this can help.

Regards
Peter Kwan

  Re: multibar chart... question
Posted by sogware on Feb-24-2012 14:43
Attachments:
Thank You~~~!!!

But legend problem...

red, blue, orange, red, blue, orange, orange...;;;
mc2.jpg

  Re: multibar chart... question
Posted by Peter Kwan on Feb-25-2012 00:49
Hi sogware,

Use:

//remove all legend entries
layer.setLegendOrder(Chart.NoLegend);

//add legend using another layer
Layer legendLayer = c.addBarLayer2(Chart.Side);
legendLayer.addDataSet(null, 0xff8888, "ABC XYZ");
legendLayer.addDataSet(null, 0x00ff88, "PQR STU");
legendLayer.addDataSet(null, 0xffcc66, "123 456");

Hope this can help.

Regards
Peter Kwan