|
//add your additional code here
<SfButton @onclick="Click">Add Segments</SfButton>
<SfChart @ref="chartInstance" Title="Particulate Levels in Rainfall">
//add your additional code here
<ChartSeriesCollection>
<ChartSeries DataSource="@ChartPoints" SegmentAxis="Segment.Y" Name="Rainfall" XName="Period" YName="RainfallInfo" Width="2" Type="ChartSeriesType.MultiColoredArea">
<ChartEmptyPointSettings Mode="EmptyPointMode.Average"></ChartEmptyPointSettings>
<ChartSegments>
@foreach (SegmentData segment in SegmentCollection)
{
<ChartSegment [email protected] [email protected]></ChartSegment>
}
</ChartSegments>
</ChartSeries>
</ChartSeriesCollection>
</SfChart>
@code {
SfChart chartInstance;
public class SegmentData
{
public double Value { get; set; }
public string Color { get; set; }
}
List<SegmentData> SegmentCollection = new List<SegmentData>();
void Click()
{
SegmentCollection.Add(new SegmentData
{
Value = 410,
Color = "red"
});
SegmentCollection.Add(new SegmentData
{
Value = 420,
Color = "blue"
});
SegmentCollection.Add(new SegmentData
{
Value = 430,
Color = "green"
});
chartInstance.Refresh();
}
//add your additional code here |