Page 1 of 1

About the using of SeriesXMLSource

Posted: Tue Mar 08, 2011 7:25 am
by 15656007
Hello,
I use the SeriesXMLSource1 to add the data to my chart ,but it happens a error . The following is my code:
codeļ¼š
LPTSTR LP;
CString STR;
m_pIndex++;
//Chart1 *m_Chart2;
VARIANT SourceSeries;
//m_Chart1.AddSeries(1);
UpdateData(TRUE);
SourceSeries.vt=VT_DISPATCH;
CSeries InputSeries=m_Chart1.Series(0);
SourceSeries.pdispVal=InputSeries;
//x axis lable format set
CAxes Axes;
CAxis Axis;
Axes=m_Chart1.get_Axis();
CAxisLabels Axislabels=Axes.GetBottom().GetLabels();
Axislabels.SetDateTimeFormat(L"yy-mm-dd HH:mm:ss");
//databinding
m_SeriesXMLSource1.SetFileName(L"D:\\DEV-DEMO\\SampleData.xml"); //This can also be a local file
m_SeriesXMLSource1.SetSeries(SourceSeries);
m_SeriesXMLSource1.SetSeriesNode(L"USA");
m_SeriesXMLSource1.SetValueSource(L"Bar");
m_SeriesXMLSource1.Open();

The attachment is the screenshot of error and the xml file. Is there something wrong in my xml file (The "X" is seted to a date value )?

Re: About the using of SeriesXMLSource

Posted: Wed Mar 09, 2011 12:10 pm
by yeray
Hi Candy,

I've loaded your XML into a VB6 chart without problems with the following code:

Code: Select all

Private Sub Form_Load()  
  TChart1.Aspect.View3D = False
  TChart1.Legend.Visible = False
  
  Dim i As Integer
  For i = 0 To 26
    With SeriesXMLSource1
      .FileName = "C:\tmp\SampleData.xml"
      
      Select Case i
      Case 0 To 25:
        TChart1.AddSeries scBar
        .ValueSource = "Bar"
      Case 26:
        TChart1.AddSeries scPoint
        .ValueSource = "Point"
      End Select
      
      .Series = TChart1.Series(i)
      TChart1.Series(i).Color = RGB(Rnd * 255, Rnd * 255, Rnd * 255)
      
      Select Case i
      Case 0:
        .SeriesNode = "USA"
      Case 1 To 22:
        .SeriesNode = (i)
      Case 23:
        .SeriesNode = "Europe"
      Case 24:
        .SeriesNode = "Asia"
      Case 25:
        .SeriesNode = "Revenue"
      End Select
      
      .Open
    End With
  Next i
End Sub
Chart.png
Chart.png (16.19 KiB) Viewed 4700 times
The error message in your image makes me think that you could be loading an string directly as Xvalue without converting it to DateTime or Double.
If you still have problems with it, could you please arrange a simple example project we can run as-is to reproduce the problem here?
Thanks in advance.