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

Message ListMessage List     Post MessagePost Message

  Data labels and dataCombineMethod Overlay
Posted by Gerrit on Apr-26-2011 18:06
Attachments:
Hi Peter,

I try to create a chart with two bars and two y axes. Every bar is assigned to one of the y axes. I use two data sets to assign the bars to the y axes. If I use the dataCombineMethod Side the data labels of the bars are displayed. But if I use the dataCombineMethod Overlay the data label of the second bar is not displayed.

code:

        XYChart chart = new XYChart(600, 400);

        // x axis
        chart.xAxis().addLabel(0, "bar1");
        chart.xAxis().addLabel(1, "bar2");

        // y axis
        Axis chartYAxis1 = chart.yAxis();
        Axis chartYAxis2 = chart.addAxis(Chart.Right, 0);

        // bar layer
        Layer dataLayer = chart.addBarLayer2(Chart.Overlay, 0);
//        Layer dataLayer = chart.addBarLayer2(Chart.Side, 0);

        DataSet dataSet1 = dataLayer.addDataSet(new double[] {10000000.0, 0.0});
        DataSet dataSet2 = dataLayer.addDataSet(new double[] {0.0, 1500.0});

        dataSet1.setUseYAxis(chartYAxis1);
        dataSet2.setUseYAxis(chartYAxis2);

        // data labels
        dataLayer.addCustomGroupLabel(0, 0, "10000000");
        dataLayer.addCustomGroupLabel(1, 1, "1500");

        chart.setPlotArea(100, 50, 400, 300);



Regards
Gerrit
testChart_side.png
testChart_overlay.png

  Re: Data labels and dataCombineMethod Overlay
Posted by Peter Kwan on Apr-27-2011 00:22
Hi Gerrit,

The:

        dataLayer.addCustomGroupLabel(1, 1, "1500");

should be:

        dataLayer.addCustomGroupLabel(0, 1, "1500");

If you are using Overlay, there is only one bar per x-position. (The bar can represent multiple data sets, but it is still one bar.) As there is only one group, the group number must be 0.

Hope this can help.

Regards
Peter Kwan