Create by code

I am trying to create a series of charts by code depending of the number of data I have. I have a chart in my xaml, created like this:

<Grid x:Name="Grid_graph">
                        <Grid.DataContext>
                            <local:LineChartViewModel></local:LineChartViewModel>
                        </Grid.DataContext>
                        <chart:SfChart>
                            <chart:SfChart.PrimaryAxis>
                                <chart:CategoryAxis Header="Horas" FontSize="14"></chart:CategoryAxis>
                            </chart:SfChart.PrimaryAxis>
                            <chart:SfChart.SecondaryAxis>
                                <chart:NumericalAxis Header="Valores" FontSize="14"></chart:NumericalAxis>
                            </chart:SfChart.SecondaryAxis>
                            <chart:LineSeries XBindingPath="Hour" YBindingPath="Value1" ItemsSource="{Binding powerInd}"></chart:LineSeries>
                        </chart:SfChart>
                    </Grid>

I want to create the grid (which I already did) and add the datacontext(done) and the "chartSfChart" to include primary/seconday axis and line series. Is it possible? Could I have a line with an example?

3 Replies

SR Samuel Rajadurai Edwin Rajamanickam Syncfusion Team April 4, 2016 12:18 PM UTC

Hi Pablo,

Thanks for contacting Syncfusion Support.

 

We have prepared sample to demonstrate how to create a SfChart in code behind. Please find the sample from the below location.

Chart_Code

 

Please refer the below documentation link for more reference.

http://help.syncfusion.com/uwp/sfchart/getting-started#create-a-simple-chart-from-code-behind


Regards,

Samuel



PA Pablo April 5, 2016 07:49 AM UTC

Thank you. That is what I was looking for. I already implemented it. 


SJ Sumathi Jayaraj Syncfusion Team April 6, 2016 05:05 AM UTC

Hi Pablo,

Thanks for the update. Please let us know if you have any queries.

Regards,
Sumathi J

Loader.
Up arrow icon