This quick start guides you through the steps of adding the FlexChart control in your Blazor application, adding data to it and displaying the data in the control. In this example, we create a data source for FlexChart by creating list of countries and their GDP values for respective years and bind the list to the FlexChart control to display the data using Bar Chart in the control.
Example Title |
コードのコピー
|
---|---|
<link rel="stylesheet" href="/_content/C1.Blazor.Core/styles.css" /> <link rel="stylesheet" href="/_content/C1.Blazor.Chart/styles.css" /> |
HTML |
コードのコピー
|
---|---|
<script src="/_content/C1.Blazor.Core/scripts.js"></script> <script src="/_content/C1.Blazor.Chart/scripts.js"></script> |
To bind FlexChart to data, set the ItemsSource property of FlexChart class of which accepts the collection of items for the FlexChart control to create a Bar chart.
The Binding/BindingX properties should contain the names of properties of items from data source collection (FlexChart.ItemsSource property).
You need to set Binding property to specify a name of numeric property that should be plotted along y-axis and BindingX property to specify a name of property that should be plotted along x-axis. The property set by BindingX can be numeric as well as string (for category x-axis).
Also, the ItemsSource/Binding/BindingX can be also specified on a series level. If any of these properties isn't set, the series uses the corresponding properties of parent chart.
Razor |
コードのコピー
|
---|---|
@using Localization @using C1.Chart; @using C1.Blazor.Chart; <FlexChart Class="chart" ChartType="ChartType.Bar" Stacking="Stacking.Stacked" HeaderContent="Country GDP (M$)" HeaderStyle="font-size:24px" LegendPosition="Position.Bottom" LegendStyle="font-size:18px" BindingX="year" ItemsSource="@GdpDataSource.GetCountryGdp()"> <SeriesCollection> <Series Name="US" Binding="US" /> <Series Name="China" Binding="China" /> <Series Name="India" Binding="India" /> <Series Name="UK" Binding="UK" /> </SeriesCollection> <AxisCollection> <Axis AxisType="AxisType.X" Position="Position.Bottom" /> <Axis AxisType="AxisType.Y" Position="Position.Left"/> </AxisCollection> |