Jump to content
Software FX Community

A question about X axis.


kelvin79

Recommended Posts

I am using ChartFX 6.2 for .NET to display my data.  But I meet a serious problem.

That is ChartFX seems use the first series I add to setup X axis. If the following series have more points than the first one, they will not be rightly displayed.

for example, I have 4 series, the first and the third one have 201 points and the others have 1539 points. The x value range of shorter series are from 0 to

8000 and the other two is from 0 to 12500. When I use OpenData to add them to ChartFX, the values from 8000 to 12500 could not be rightly displayed.

And the last X axis label is 8000.

The following is my codes

  int seriesNum = 4;

  double[][] xData = new double[seriesNum][];

  double[][] yData = new double[seriesNum][];

  xData[0] = m_DataSource.GetXData(0);

  yData[0] = m_DataSource.GetYData(0);

  xData[1] = m_DataSource.GetXData(1);

  yData[1] = m_DataSource.GetYData(1);

  xData[2] = m_DataSource.GetXData(2);

  yData[2] = m_DataSource.GetYData(2);

  xData[3] = m_DataSource.GetXData(3);

  yData[3] = m_DataSource.GetYData(3);

  int maxPointNum = 0;

  for (int i = 0; i < seriesNum; i++)

  {

  if (xData != null)

  {

  maxPointNum = Math.Max(maxPointNum, xData.Length);

  }

  }

  m_Chart.OpenData(COD.Values, seriesNum, maxPointNum);

  m_Chart.OpenData(COD.XValues, seriesNum, maxPointNum);

  //

  ChartDataObj chartValue = m_Chart.Value;

  ChartDataObj chartXValue = m_Chart.XValue;

  //

  for (int j = 0; j < seriesNum; j++)

  {

  if (xData[j] == null)

  continue;

  for(int i = 0; i < xData[j].Length; i++)

  {

  chartXValue[j, i] = xData[j];

  chartValue[j, i] = yData[j];

  }

  }

  //

  m_Chart.CloseData(COD.XValues);

  m_Chart.CloseData(COD.Values);

  m_Chart.Series[0].Gallery = Gallery.Scatter;

  m_Chart.Series[0].Color = Color.Red;

  m_Chart.Series[1].Gallery = Gallery.Lines;

  m_Chart.Series[1].Color = Color.Red;

  m_Chart.Series[2].Gallery = Gallery.Scatter;

  m_Chart.Series[2].Color = Color.Blue;

  m_Chart.Series[3].Gallery = Gallery.Lines;

  m_Chart.Series[3].Color = Color.Blue;

 Is there something wrong? I have checked the x and y data have no problem.

And how ChartFX setups X and Y axis according to the data automatically?

 

Link to comment
Share on other sites

All series have the same amount of points (maxPointNum).

The X-Axis should be adjusted to the Min and Max value of all series.

Replacing the protion of your code that deals with your data (which I don't have) with the following code renders correctly:

xData[0] = new double [] {0,100,8000};

yData[0] =

new double [] {50,100,60};xData[1] = new double [] {0,100,8000};

yData[1] =

new double [] {50,100,60};xData[2] = new double [] {0,100,8000,12500};

yData[2] =

new double [] {50,100,60,80};xData[3] = new double [] {0,100,8000,12500};

yData[3] =

new double [] {50,100,60,80};

 Notice that 12500 may not be displaying as a label at the end of the X-Axis simply because the Step chosen is not a multiple of 12500, that doesn't mean the Axis Max is not 12500. Do you see the data at 12500 or is it clipped?

Link to comment
Share on other sites

Thank you very much for your quick reply.

>All series have the same amount of points (maxPointNum).

Is that means I should allocate space to make all my series have the same length, using Chart.Hidden to fill the empty points? ChartFX don't do that for me?

I understand why 12500 may not be the last label of x axis, but my problem is actually that the last scale of x axis being wiredrawed very long. The label of 

scale beginning is 8000 and the ending is 8000,too. The data between 8000 to 1250 is displayed in this long scale. Perhaps I need to give a screen snap

shot tomorrow. It seems ChartFX only use the first series's X value to calculate Max and Min value. I must make some mistakes, but I can't find where...

 In addition, I met the same problem when I use ListProvider to populate data ...

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...