Doesn't show chart

4 posts, 0 answers
  1. Wallace Santos
    Wallace Santos avatar
    5 posts
    Member since:
    Aug 2007

    Posted 04 Apr 2010 Link to this post

    Hi folks

    When I built a chart setting the property IsDateTime = true in below code, the chart it does't show:

    "

    List<double> line1 = new List<double>(); 
    List<double> line2 = new List<double>();
    List<double> line3 = new List<double>();
    List<double> line4 = new List<double>();
    List<double> line5 = new List<double>();
    List<double> line6 = new List<double>();
    List<double> line7 = new List<double>();

    DateTime startDate = new DateTime(2010,1,1); 
    DateTime endDate = new DateTime(2010,1,15);

    string xml = e.Result; 
    using (XmlReader reader = XmlReader.Create(new System.IO.StringReader(xml)))
    {
       reader.ReadToDescendant("data");    
       if (reader.Depth > 0) {
          do {  
             // All attribute data are double values
             // this.loop adds 7 items into each collection
             line1.Add(double.Parse(reader.GetAttribute("data1")));
             line2.Add(double.Parse(reader.GetAttribute("data2")));  
             line3.Add(double.Parse(reader.GetAttribute("data3")));  
             line4.Add(double.Parse(reader.GetAttribute("data4")));  
             line5.Add(double.Parse(reader.GetAttribute("data5")));
             line6.Add(double.Parse(reader.GetAttribute("data6")));
             line7.Add(double.Parse(reader.GetAttribute("data7")));
          }while (reader.ReadToNextSibling("data"));  
       }

    }
    this._chart.DefaultView.ChartArea.AxisX.AutoRange = false; 
    this._chart.DefaultView.ChartArea.AxisX.IsDateTime = true; 
    this._chart.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "dd/MM/yyyy"; 
    this._chart.DefaultView.ChartArea.AxisX.LabelRotationAngle = -45; 
    this._chart.DefaultView.ChartArea.AxisX.MinValue = startDate.ToOADate(); 
    this._chart.DefaultView.ChartArea.AxisX.MaxValue = endDate.ToOADate();  
    this._chart.DefaultView.ChartArea.AxisX.Step = startDate.AddDays(1).ToOADate() - startDate.ToOADate(); 
    this.AddSeriesMapping("Series 1", 0); 
    this.AddSeriesMapping("Series 2", 1); 
    this.AddSeriesMapping("Series 3", 2);
    this.AddSeriesMapping("Series 4", 3);
    this.AddSeriesMapping("Series 5", 4); 
    this.AddSeriesMapping("Series 6", 5); 
    this.AddSeriesMapping("Series 7", 6);

    List<double[]> itemsSource = new List<double[]>();

    itemsSource.Add(line1.ToArray());
    itemsSource.Add(line2.ToArray());
    itemsSource.Add(line3.ToArray());
    itemsSource.Add(line4.ToArray());
    itemsSource.Add(line5.ToArray());
    itemsSource.Add(line6.ToArray());
    itemsSource.Add(line7.ToArray());

    this._chart.ItemsSource = itemsSource; 
    this._chart.DefaultView.ChartArea.ZoomScrollSettingsX.ScrollMode = ScrollMode.ScrollAndZoom; 
    this._chart.DefaultView.ChartArea.ZoomScrollSettingsY.ScrollMode = ScrollMode.ScrollAndZoom; 
    this._chart.DefaultView.ChartArea.AxisY.MajorGridLinesVisibility = Visibility.Visible;
    this._chart.DefaultView.ChartArea.AxisY.MinorGridLinesVisibility = Visibility.Visible; 
    this._chart.DefaultView.ChartArea.AxisX.MajorGridLinesVisibility = Visibility.Visible; 
    this._chart.DefaultView.ChartLegend.Margin = new Thickness(15, 0, 0, 0);

     

     

    "

    My question is: This is a bug?

    Thanks.

     

     

     

     

     

     

     

     

     

  2. Ves
    Admin
    Ves avatar
    2926 posts

    Posted 07 Apr 2010 Link to this post

    Hello Wallace,

    The short answer would be no, no bug here. But let me provide you with some info on RadChart axes.

    A point (or a bar) in RadChart is drawn according to two coordinates -- X and Y. They are represented by the XValue and YValue properties of the DataPoint object (well, there are special cases like CandleStick charts, where Open, High, Low and Close properties are used). So, the YValue property is a must -- if it is not present - by default it is 0 and the point/bar will be with 0 height. The XValue is optional -- if you supply it the point/bar will be drawn at that position. If it is not provided - RadChart will draw the points/bars next to each other.

    By default RadChart will calculate the range for each axis, however you can change that by setting the AutoRange property to false. I can see you have already done this. But setting MinValue and MaxValue for AxisX you force the chart to display only items with XValue falling between these values. Your code shows, that you add series mappings but it does not show if these series mappings have ItemMapping for XValue property. My bet would be -- there isn't any. The reason -- I can see the chart is populated by a list of arrays of doubles, so each array would represent a DataSeries and each member of that array (a double value) would represent a DataPoint. There does not seem to be enough information about the position of that point along the XAxis - hence RadChart will start from 1 and add the items next to each other. But MinValue and MaxValue are set and their values are close to 40000 (the OLE Automation date equivalent), so the items are there, but they are out of the axis range.

    To fix this, you need to provide the necessary information for XValue for each DataPoint  -- you may need to replace the double values by an object, which would contain the double value as well as a DateTime value for positioning along the X axis. You can find more details about X axis and series mappings here and here. You can find an example showing series mappings with DateTime values here.

    Sincerely,
    Ves
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. Ves
    Admin
    Ves avatar
    2926 posts

    Posted 07 Apr 2010 Link to this post

    Hello Wallace,

    The short answer would be no, no bug here. But let me provide you with some info on RadChart axes.

    A point (or a bar) in RadChart is drawn according to two coordinates -- X and Y. They are represented by the XValue and YValue properties of the DataPoint object (well, there are special cases like CandleStick charts, where Open, High, Low and Close properties are used). So, the YValue property is a must -- if it is not present - by default it is 0 and the point/bar will be with 0 height. The XValue is optional -- if you supply it the point/bar will be drawn at that position. If it is not provided - RadChart will draw the points/bars next to each other.

    By default RadChart will calculate the range for each axis, however you can change that by setting the AutoRange property to false. I can see you have already done this. But setting MinValue and MaxValue for AxisX you force the chart to display only items with XValue falling between these values. Your code shows, that you add series mappings but it does not show if these series mappings have ItemMapping for XValue property. My bet would be -- there isn't any. The reason -- I can see the chart is populated by a list of arrays of doubles, so each array would represent a DataSeries and each member of that array (a double value) would represent a DataPoint. There does not seem to be enough information about the position of that point along the XAxis - hence RadChart will start from 1 and add the items next to each other. But MinValue and MaxValue are set and their values are close to 40000 (the OLE Automation date equivalent), so the items are there, but they are out of the axis range.

    To fix this, you need to provide the necessary information for XValue for each DataPoint  -- you may need to replace the double values by an object, which would contain the double value as well as a DateTime value for positioning along the X axis. You can find more details about X axis and series mappings here and here. You can find an example showing series mappings with DateTime values here.

    Sincerely,
    Ves
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  4. Wallace Santos
    Wallace Santos avatar
    5 posts
    Member since:
    Aug 2007

    Posted 07 Apr 2010 Link to this post

    Hi Ves

    Make sense. I read these docs/sample but...
    Thanks a lot for your answer and I would study a little bit more the situation to fix it.

    Regards

    Wallace
Back to Top