Spline Chart
The Ignite UI for React spline chart belongs to a group of category charts and is rendered using a collection of points connected by smooth curves of spline. Values are represented on the y-axis and categories are displayed on the x-axis. IgrSplineSeries emphasizes the amount of change over a period of time or compares multiple items as well as the relationship of parts to a whole by displaying the total of the plotted values. The React spline chart is identical to the React line chart in all aspects except that line connecting data points has spline interpolation and smoothing for improved presentation of data.
Demo
Required Axes
The React data chart component provides various types of axes but only the following types of axes can be used with IgrSplineSeries.
Required Data
The IgrSplineSeries has the following data requirements:
- The data source must be an array or a list of data items.
- The data source must contain at least one data item otherwise the chart will not render the
IgrSplineSeries. - All data items must contain at least one data column (string or date time) which should be mapped to the
Labelproperty of the category axis (e.g.IgrCategoryXAxis) - All data items must contain at least one numeric data column which should be mapped using the
ValueMemberPathproperty of theIgrSplineSeries.
You can use the SampleCategoryData as data source which meets above data requirements.
public dataSource: any[] = SampleCategoryData.create();
Required Modules
Creation of the IgrSplineSeries requires the following modules:
// axis' modules:
import { IgrNumericYAxis } from 'igniteui-react-charts';
import { IgrCategoryXAxis } from 'igniteui-react-charts';
// series' modules:
import { IgrSplineSeries } from 'igniteui-react-charts';
// data chart's modules:
import { IgrDataChart } from 'igniteui-react-charts';
import { IgrDataChartCoreModule } from 'igniteui-react-charts';
import { IgrDataChartCategoryModule } from 'igniteui-react-charts';
// registering data chart's modules:
IgrDataChartCoreModule.register();
IgrDataChartCategoryModule.register();
Code Example
This code demonstrates how to create an instance of the Ignite UI for React data chart with IgrSplineSeries and bind it to a data source.
<IgrDataChart
dataSource={this.dataSource}
width="700px"
height="500px">
{/* axes */}
<IgrCategoryXAxis name="xAxis" label="Year" />
<IgrNumericYAxis name="yAxis" />
{/* series */}
<IgrSplineSeries
name="series1"
xAxisName="xAxis"
yAxisName="yAxis"
valueMemberPath="USA" />
</IgrDataChart>
const series1 = new IgrSplineSeries({ name: "series1" });
series1.valueMemberPath = "USA";
series1.xAxisName = "xAxis";
series1.yAxisName = "yAxis";
const yAxis = new IgrNumericYAxis({ name: "yAxis" });
const xAxis = new IgrCategoryXAxis({ name: "xAxis" });
xAxis.label = "Year";
this.chart = new IgrDataChart({ name: "chart" });
this.chart.dataSource = SampleCategoryData.create();
this.chart.axes.add(yAxis);
this.chart.axes.add(xAxis);
this.chart.series.add(series1);