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

Message ListMessage List     Post MessagePost Message

  basic chart
Posted by Ckane on May-03-2012 06:40
below is a code snippet.  All values and arrays are valid.

Chart shows, but no axis' or data.   Just a blank chart

What am I doing wrong?

XYChart c1 = new XYChart(720, 300, 0xccccff, 0x000000, 1);
             c1.addTitle("DR Log Data", "Times New Roman Bold Italic", 15, 0xffffff).setBackground(0x000080)

            LineLayer layer0 = c1.addLineLayer2();
            layer0.addDataSet(data0, 0xff0000, "layer 0").setDataSymbol(Chart.GlassSphere2Shape, 11);
            layer0.setLineWidth(3);
            c1.setBackground(c1.linearGradientColor(0, 0, 0, 100, 0x99ccff, 0xffffff),0x888888);
            c1.setRoundedFrame();
            DateTime startDate = xaxis[0];
           DateTime endDate = xaxis[numCol - 1];

            c1.xAxis().setDateScale(startDate, endDate);


             winChartViewer1.Image = c1.makeImage();

  Re: basic chart
Posted by Peter Kwan on May-03-2012 23:44
Hi Ckane,

The issue is because your code has set up the x-axis scale, but it does not provide x-coordinates for your data points. So for the data points, ChartDirector will use the default x-coordinates, which are 0, 1, 2, 3, ..... (These coordinates are designed to work with a label based x-axis configured with Axis.setLabels, but not with the date scale x-axis.)

In general, ChartDirector will not assume the (x, y) data values to be determined by the axis scale. For example, if you set the y-axis scale as 0 to 100, your data values will not suddenly spread evenly from 0 to 100.

For your case, to solve the problem, you may use setXData or setXData2 to provide the x-coordinates of your data points. For example:

//assume the xaxis is an array that contains the coordinates of your data points
layer0.setXData(xaxis);

or

//Just spread the data points evenly between the startDate and endDate. This assumes
//your data points are evenly spaced in the x-direction.
layer0.setXData2(startDate, endDate);

Hope this can help.

Regards
Peter Kwan