blazor-devexpress-dot-blazor-dot-chartseriespointcustomizationsettings-efb758a2.md
Provides access to the point’s label settings.
Namespace : DevExpress.Blazor
Assembly : DevExpress.Blazor.v25.2.dll
NuGet Package : DevExpress.Blazor
public IChartSeriesLabel PointLabel { get; }
| Type | Description |
|---|---|
| IChartSeriesLabel |
The point label.
|
Use this property in the CustomizeSeriesPoint event handler to specify the label color, position, and visibility.
To define appearance settings that apply to all the labels in a series, use the DxChartSeriesLabel component.
Tip
Individual label settings have a priority over the common label settings.
The following example demonstrates how to:
use the DxChartSeriesLabel component to specify the position of all labels;
use the DxChartSeriesLabelConnector component to customize connectors between data points and labels;
handle the CustomizeSeriesPoint event to show only labels whose values are between 25 and 75.
@inject WeatherForecastService ForecastService
<DxChart Data="@ChartData" CustomizeSeriesPoint="@PreparePointLabel">
<DxChartLineSeries SummaryMethod="@(i => (int)i.Average())"
ValueField="@((WeatherForecast i) => i.TemperatureF)"
ArgumentField="@(i => i.Date.Date)"
Name="Temperature, F">
<DxChartSeriesLabel Position="RelativePosition.Outside">
<DxChartSeriesLabelConnector Visible="true" Width="3" />
</DxChartSeriesLabel>
</DxChartLineSeries>
</DxChart>
@code {
WeatherForecast[] ChartData;
protected override async Task OnInitializedAsync() {
ChartData = await ForecastService.GetForecastAsync();
}
protected void PreparePointLabel(ChartSeriesPointCustomizationSettings pointSettings) {
double value = (double)pointSettings.Point.Value;
if (value > 25 && value < 75)
pointSettings.PointLabel.Visible = true;
}
}
using System;
public class WeatherForecast {
public DateTime Date { get; set; }
public int TemperatureC { get; set; }
public double TemperatureF => Math.Round((TemperatureC * 1.8 + 32), 2);
public double Precipitation { get; set; }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
public class WeatherForecastService {
// ...
private List<WeatherForecast> Forecast { get; set; }
public WeatherForecastService() {
// ...
Forecast = CreateForecast();
}
// ...
private List<WeatherForecast> CreateForecast() {
var rng = new Random();
DateTime startDate = DateTime.Now;
return Enumerable.Range(1, 15).Select(index => new WeatherForecast {
Date = startDate.AddDays(index),
TemperatureC = rng.Next(-20, 55),
}).ToList();
}
public Task<WeatherForecast[]> GetForecastAsync(CancellationToken ct = default) {
return Task.FromResult(Forecast.ToArray());
}
}
// ...
builder.Services.AddSingleton<WeatherForecastService>();
Run Demo: Charts - Series Label Customization
See Also
ChartSeriesPointCustomizationSettings Class