|
| 1 | +--- |
| 2 | +title: ScatterLine |
| 3 | +page_title: Chart for Blazor | ScatterLine |
| 4 | +description: Overview of the ScatterLine Chart for Blazor |
| 5 | +slug: components/chart/types/scatterline |
| 6 | +tags: telerik,blazor,chart,scatterline |
| 7 | +published: True |
| 8 | +position: 0 |
| 9 | +--- |
| 10 | + |
| 11 | +# ScatterLine Chart |
| 12 | + |
| 13 | +The **ScatterLine** chart is very similar to the [Scatter]({%slug components/chart/types/scatter%}) chart—it shows data as points defined by their items' values, but the points are connected by lines and thus it can account for missing values in a series. Its x-axis is numerical and does not require items. |
| 14 | + |
| 15 | +You would usually use ScatterLine charts for showing the relation between different sets of data, for example scientific (experimental) results, or when you need to have two numerical axes on a line-type chart. |
| 16 | + |
| 17 | +>caption ScatterLine chart. Results from the first code snippet below |
| 18 | +
|
| 19 | + |
| 20 | + |
| 21 | +@[template](/_contentTemplates/chart/link-to-basics.md#understand-basics-and-databinding-first) |
| 22 | + |
| 23 | +To create a scatter chart: |
| 24 | + |
| 25 | +1. add a `ChartSeries` to the `ChartSeriesItems` collection |
| 26 | +2. set its `Type` property to `ChartSeriesType.ScatterLine` |
| 27 | +3. provide a data collection to its `Data` property, which contains numerical data for the X and Y axes |
| 28 | + |
| 29 | + |
| 30 | +>caption A bubble chart that shows projected population change on a plot of life expectancy versus fertility rate |
| 31 | +
|
| 32 | +````CSHTML |
| 33 | +@* ScatterLine Series *@ |
| 34 | +
|
| 35 | +<TelerikChart> |
| 36 | + <ChartTitle Text="Charge current vs. charge time"></ChartTitle> |
| 37 | + <ChartLegend Visible="true"></ChartLegend> |
| 38 | +
|
| 39 | + <ChartSeriesItems> |
| 40 | + <ChartSeries Type="ChartSeriesType.ScatterLine" |
| 41 | + Data="@Series1Data" |
| 42 | + Name="0.8C" |
| 43 | + XField="@nameof(ModelData.X)" |
| 44 | + YField="@nameof(ModelData.Y)"> |
| 45 | + </ChartSeries> |
| 46 | +
|
| 47 | + <ChartSeries Type="ChartSeriesType.ScatterLine" |
| 48 | + Data="@Series2Data" |
| 49 | + Name="1.6C" |
| 50 | + XField="@nameof(ModelData.X)" |
| 51 | + YField="@nameof(ModelData.Y)"> |
| 52 | + </ChartSeries> |
| 53 | +
|
| 54 | + <ChartSeries Type="ChartSeriesType.ScatterLine" |
| 55 | + Data="@Series3Data" |
| 56 | + Name="3.1C" |
| 57 | + XField="@nameof(ModelData.X)" |
| 58 | + YField="@nameof(ModelData.Y)"> |
| 59 | + </ChartSeries> |
| 60 | + </ChartSeriesItems> |
| 61 | +
|
| 62 | + <ChartXAxes> |
| 63 | +
|
| 64 | + <ChartXAxis Max="100"> |
| 65 | + <ChartXAxisTitle Text="Time"></ChartXAxisTitle> |
| 66 | + <ChartXAxisLabels Format="{0}m"></ChartXAxisLabels> |
| 67 | + </ChartXAxis> |
| 68 | + </ChartXAxes> |
| 69 | +
|
| 70 | + <ChartYAxes> |
| 71 | + <ChartYAxis Max="100"> |
| 72 | + <ChartYAxisTitle Text="Charge"></ChartYAxisTitle> |
| 73 | + <ChartYAxisLabels Format="{0}%"></ChartYAxisLabels> |
| 74 | + </ChartYAxis> |
| 75 | +
|
| 76 | + </ChartYAxes> |
| 77 | +</TelerikChart> |
| 78 | +
|
| 79 | +@code { |
| 80 | + public class ModelData |
| 81 | + { |
| 82 | + public int X { get; set; } |
| 83 | + public int Y { get; set; } |
| 84 | + } |
| 85 | +
|
| 86 | + public List<ModelData> Series1Data = new List<ModelData>() |
| 87 | + { |
| 88 | + new ModelData() { X = 10, Y = 10 }, |
| 89 | + new ModelData() { X = 15, Y = 20 }, |
| 90 | + new ModelData() { X = 20, Y = 25 }, |
| 91 | + new ModelData() { X = 32, Y = 40 }, |
| 92 | + new ModelData() { X = 43, Y = 50 }, |
| 93 | + new ModelData() { X = 55, Y = 60 }, |
| 94 | + new ModelData() { X = 60, Y = 70 }, |
| 95 | + new ModelData() { X = 70, Y = 80 }, |
| 96 | + new ModelData() { X = 90, Y = 100 }, |
| 97 | + }; |
| 98 | +
|
| 99 | + public List<ModelData> Series2Data = new List<ModelData>() |
| 100 | + { |
| 101 | + new ModelData() { X = 10, Y = 40 }, |
| 102 | + new ModelData() { X = 17, Y = 50 }, |
| 103 | + new ModelData() { X = 18, Y = 70 }, |
| 104 | + new ModelData() { X = 35, Y = 90 }, |
| 105 | + new ModelData() { X = 47, Y = 95 }, |
| 106 | + new ModelData() { X = 60, Y = 100 }, |
| 107 | + }; |
| 108 | +
|
| 109 | + public List<ModelData> Series3Data = new List<ModelData>() |
| 110 | + { |
| 111 | + new ModelData() { X = 10, Y = 70 }, |
| 112 | + new ModelData() { X = 13, Y = 90 }, |
| 113 | + new ModelData() { X = 25, Y = 100 }, |
| 114 | + }; |
| 115 | +} |
| 116 | +```` |
| 117 | + |
| 118 | + |
| 119 | +## ScatterLine Chart Specific Appearance Settings |
| 120 | + |
| 121 | +@[template](/_contentTemplates/chart/link-to-basics.md#markers-line-scatter) |
| 122 | + |
| 123 | +@[template](/_contentTemplates/chart/link-to-basics.md#color-line-scatter) |
| 124 | + |
| 125 | +@[template](/_contentTemplates/chart/link-to-basics.md#line-style-line) |
| 126 | + |
| 127 | +## See Also |
| 128 | + |
| 129 | + * [Live Demo: ScatterLine Chart](https://demos.telerik.com/blazor-ui/chart/scatter-line-chart) |
0 commit comments