This is a migrated thread and some comments may be shown as answers.

Binding Data Source, Mutiple Y Axes

1 Answer 55 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Keith
Top achievements
Rank 1
Keith asked on 19 Jul 2011, 10:36 PM
I'm new to the Silverlight controls, and I'm attempting to bind an xml file to a chart with 2 Y axes and hitting a runtime error. I'm using a mix of 2 different training materials and not sure if I'm mixing code that I shouldn't. For the binding I've looked at the 06_XML project in the new courseware material and forum item http://www.telerik.com/community/forums/silverlight/chart/how-to-bind-a-xml-file-to-silverlight-pie-chart.aspx. For the multiple Y Axis use case I've looked at the demo on http://demos.telerik.com/silverlight/#Chart/MultipleYAxes.

I can see in the debugger that the data is being loaded from the xml file, but the ItemSource assignment is cuainsg a crashing. The error message is "System.FormatException: Input string was not in a correct format. at System.Number.ParseDouble(String value, NumberStyles options,"

I'm pretty sure the issue is with the xaml - I've tried several combinations from the use cases (xaml and telerik objects are my weakest points right now).

Anyhelp is appreciated.

Here's my current MainPage.xaml

<UserControl xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"  x:Class="SilverlightCharts.MainPage"
    xmlns:control="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Charting"
    xmlns:chart="clr-namespace:Telerik.Windows.Controls.Charting;assembly=Telerik.Windows.Controls.Charting" mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
  
    <Grid x:Name="LayoutRoot" Background="White">
        <telerik:RadChart x:Name="MarketReplay" >
  
            <telerik:RadChart.SeriesMappings>
                <telerik:SeriesMapping>
                    <telerik:SeriesMapping.SeriesDefinition>
                        <telerik:BarSeriesDefinition AxisName="Volume"/>
                    </telerik:SeriesMapping.SeriesDefinition>
                    <telerik:ItemMapping DataPointMember="YValue" FieldName="volume"/>
                    <telerik:ItemMapping DataPointMember="XValue" FieldName="period"/>
                </telerik:SeriesMapping>
                <telerik:SeriesMapping>
                    <telerik:SeriesMapping.SeriesDefinition>
                        <telerik:LineSeriesDefinition AxisName="Price" />
                    </telerik:SeriesMapping.SeriesDefinition>
                    <telerik:ItemMapping DataPointMember="YValue" FieldName="price"/>
                    <telerik:ItemMapping DataPointMember="XValue" FieldName="period"/>
                </telerik:SeriesMapping>
            </telerik:RadChart.SeriesMappings>
    </telerik:RadChart>
    </Grid>
</UserControl>

 

 


MainPage.xaml.cs is here

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Xml.Linq;
using Telerik.Windows.Controls.Charting;
  
namespace SilverlightCharts {
    public partial class MainPage : UserControl {
        public MainPage() {
            InitializeComponent();
            XDocument document = XDocument.Load("marketdata.xml");
  
            List<MarketData> mktData =
                (from list in document.Descendants("item")
                    select new MarketData() {
                        period = list.Attribute("period").Value,
                        volume = list.Attribute("volume").Value,
                        price = list.Attribute("price").Value,
                    }).ToList();
            this.MarketReplay.ItemsSource = mktData;
        }
    }
}

The MarketDate class and marketdata.xml are here:
namespace SilverlightCharts {
    public class MarketData {
        public string period { get; set; }
        public string volume { get; set; }
        public string price { get; set; }
    }
}

<?xml version="1.0" encoding="utf-8"?>
<items security="ibm">
    <item period="3/1/2011" volume="15" price="89.11"/>
    <item period="3/2/2011" volume="5" price="84.55"/>
    <item period="3/3/2011" volume="34" price="90.01"/>
    <item period="3/4/2011" volume="11" price="91.11"/>
    <item period="3/5/2011" volume="11" price="91.01"/>
    <item period="3/8/2011" volume="29" price="88.01" />
    <item period="3/9/2011" volume="33" price="75.21" />
    <item period="3/10/2011" volume="31" price="34.99" />
    <item period="3/11/2011" volume="40" price="101" />
    <item period="3/12/2011" volume="27" price="101" />
</items>

1 Answer, 1 is accepted

Sort by
0
Missing User
answered on 21 Jul 2011, 10:47 AM
Hello Keith,

Our records indicate, that this post is identical to the formal ticket which you have opened on the same matter. In order to avoid duplicate posts, we can continue our communication in the formal ticket in question. Thank you in advance for your understanding.

Best wishes,
Polina
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
Chart
Asked by
Keith
Top achievements
Rank 1
Answers by
Missing User
Share this question
or