First time user: Cannot draw a simpe lien chart
Here is what I am doing and nothing is happening. I don't see anything drawn on the chart. Can you pls help me figure out what I am doing wrong?
//in .cs file:
class SeriesData {
string m_year;
double m_portVal;public SeriesData(string year, double portVal) {
m_year = year;
m_portVal = portVal;
}public string Year { get; set; }
public double PortVal { get; set; }
}
ObservableCollection obsvrColl = null;
later when a button is clicked:
Foo() {obsvrColl = new ObservableCollection(); for (int i = 0; i < m_userData.Years; i++)
{
obsvrColl.Add(new SeriesData(i.ToString(), i*100));
}series1.ItemsSource = obsvrColl;
series1.XBindingPath = "Year";
series1.YBindingPath = "PortVal";
chartGrowth.Series.Add(series1);this.DataContext = this;}
//in XAML:
<syncfusion:SfChart.PrimaryAxis>
<syncfusion:CategoryAxis Header="Demands" FontSize="12"/>
</syncfusion:SfChart.PrimaryAxis>
<!--Initialize the vertical axis for SfChart-->
<syncfusion:SfChart.SecondaryAxis>
<syncfusion:NumericalAxis Header="Values" FontSize="12"/>
</syncfusion:SfChart.SecondaryAxis>
<!--Adding Legend to the SfChart-->
<syncfusion:SfChart.Legend>
<syncfusion:ChartLegend Visibility="Visible"/>
</syncfusion:SfChart.Legend>
</syncfusion:SfChart>
SIGN IN To post a reply.
3 Replies
DA
Devi Aruna Maharasi Murugan
Syncfusion Team
March 1, 2017 11:44 AM UTC
Hi Berk,
Thanks for contacting Syncfusion Support.
Since the XBindingPath and YBindingPath property values (Year, PortVal) are not assigned and the ObservableCollection for series items source is not defined properly, the chart series does not render. We have prepared a demo sample based on your requirement with the reference of provided code snippet. The sample can be downloaded from below link,
Sample: LineSeries173907
Please refer our UG documentation link for getting started into SfChart,
Regards,
Devi
BC
Berk Celebisoy
March 1, 2017 05:18 PM UTC
Devi - Thank you for getting back to me. Your sample code solves my problem. You're awesome!!! Thanks! ;-)
DA
Devi Aruna Maharasi Murugan
Syncfusion Team
March 2, 2017 03:52 AM UTC
Hi Berk,
Thanks for your update.
Please let us know, if you need any further assistance on this.
Regards,
Devi
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
BC Berk Celebisoy
- Feb 28, 2017 06:51 AM UTC
- Mar 2, 2017 03:52 AM UTC