Events
The charts raise events when the user presses or hovers the data, and while they update. The chart events receive
the points as ChartPoint instances, which give access to the data source, the coordinate and the drawn shape of
each point. The series raise their own events, typed with the model and the geometry of the series. Every event that
a view model may need also has a command, so it can be bound in MVVM.
Every event is listed in the API explorer: IChartView, CartesianChart, Series, PointerCommandArgs and HoverCommandArgs.
Chart events
Every chart control (CartesianChart, PieChart, PolarChart and the others) has these events:
DataPointerDown: the pointer went down on the chart. It receives the points under the pointer, found with theFindingStrategyof the chart. Command:DataPointerDownCommand, its parameter is theIEnumerable<ChartPoint>of the points.HoveredPointsChanged: the hovered points changed, these are the points the tooltip shows. It receives the points that are now hovered and the points that are no longer hovered; either list can benull. Command:HoveredPointsChangedCommand, its parameter is aHoverCommandArgswithNewPointsandOldPoints.VisualElementsPointerDown: the pointer went down on one or more visual elements of the chart. Command:VisualElementsPointerDownCommand, its parameter is aVisualElementsEventArgs.Measuring: the chart is about to measure its elements, the first step of an update.UpdateStarted: the chart measured its elements and is about to draw them. Command:UpdateStartedCommand, its parameter is aChartCommandArgs.UpdateFinished: the chart finished drawing, when no animation is still running.
ChartPointPointerDown is obsolete, use DataPointerDown with a FindingStrategy that takes the closest point,
such as CompareAllTakeClosest.
The hovered points do not depend on the tooltip being visible: HoveredPointsChanged also fires when
TooltipPosition is Hidden. A series with IsHoverable set to false is left out of the hovered points.
chart.DataPointerDown += (sender, points) =>
{
foreach (var point in points)
Trace.WriteLine($"pressed {point.Context.DataSource}");
};
chart.HoveredPointsChanged += (sender, newPoints, oldPoints) =>
{
// newPoints are now hovered, oldPoints are no longer hovered
};
The geo maps article explains how these events work on a map, where they report the lands. The map has the events but not the commands.
Pointer events
Use the OnPointerDownCallback, OnPointerMoveCallback and OnPointerUpCallback parameters of the chart. They
receive the PointerEventArgs of Blazor, OffsetX and OffsetY are the position of the pointer relative to the
chart:
<CartesianChart
@ref="chart"
Series="series"
OnPointerDownCallback="OnPointerDown">
</CartesianChart>
private CartesianChart chart;
private void OnPointerDown(PointerEventArgs e)
{
var position = new LvcPointD(e.OffsetX, e.OffsetY);
var points = chart.GetPointsAt(position);
// ...
}
Hovered and pressed points
This sample sets the FindingStrategy of the chart to ExactMatch, so a column is hovered only while the pointer is
inside the drawn column. When the hovered points change, it sets a black Stroke on the columns in the new points
and clears it on the old ones. On a press, it asks the chart for the points at the pointer position with
GetPointsAt and toggles a yellow Fill on them; setting Fill back to null restores the paint of the series.

@page "/Events/Tutorial"
@using LiveChartsCore.Drawing;
@using LiveChartsCore.Kernel;
@using LiveChartsCore.Kernel.Events;
@using LiveChartsCore.Kernel.Sketches;
@using LiveChartsCore.SkiaSharpView.Blazor;
@using LiveChartsCore;
@using LiveChartsCore.SkiaSharpView;
@using LiveChartsCore.SkiaSharpView.Painting;
@using SkiaSharp;
<CartesianChart
@ref="_chart"
Series="@series"
FindingStrategy="LiveChartsCore.Measure.FindingStrategy.ExactMatch"
OnPointerDownCallback="OnPointerDown">
</CartesianChart>
@code {
private CartesianChart _chart;
private ISeries[] series = new ISeries[]
{
new ColumnSeries<double>
{
Values = new double[] { 1, 5, 4, 3 },
Stroke = new SolidColorPaint(SKColors.Transparent)
},
new ColumnSeries<double>
{
Values = new double[] { 3, 2, 6, 2 },
Stroke = new SolidColorPaint(SKColors.Transparent)
}
};
private HashSet<ChartPoint> _activePoints = new HashSet<ChartPoint>();
protected override void OnAfterRender(bool firstRender)
{
base.OnAfterRender(firstRender);
_chart.HoveredPointsChanged += OnHoveredChanged;
}
private void OnPointerDown(PointerEventArgs e)
{
var foundPoints = _chart.GetPointsAt(new LvcPointD(e.OffsetX, e.OffsetY));
foreach (var point in foundPoints)
{
var visual = point.Context.Visual!;
if (!_activePoints.Contains(point))
{
visual.Fill = new SolidColorPaint { Color = SKColors.Yellow };
_activePoints.Add(point);
}
else
{
visual.Fill = null;
_activePoints.Remove(point);
}
}
}
private void OnHoveredChanged(IChartView chart, IEnumerable<ChartPoint>? newItems, IEnumerable<ChartPoint>? oldItems)
{
foreach (var hovered in newItems ?? System.Array.Empty<ChartPoint>())
{
hovered.Context.Visual!.Stroke = new SolidColorPaint(SKColors.Black, 3);
}
foreach (var hovered in oldItems ?? System.Array.Empty<ChartPoint>())
{
hovered.Context.Visual!.Stroke = null;
}
}
}
Find the points under the pointer
GetPointsAt returns the points at a position in pixels, and GetVisualsAt returns the visual elements there.
var points = chart.GetPointsAt(position);
var visuals = chart.GetVisualsAt(position);
GetPointsAt takes the finding strategy as an argument, it does not read the FindingStrategy of the chart. The
default, Automatic, uses the strategy the series prefer: for the columns of the previous sample,
CompareOnlyXTakeClosest, which returns a column of each series in the category. To find the same points as the
chart, pass its strategy:
var chart = (ICartesianChartView)args.Chart;
var points = chart.GetPointsAt(args.PointerPosition, chart.FindingStrategy); // mark
DataPointerDown already uses the FindingStrategy of the chart. The strategies are described in the
tooltips article.
When none of them fits, a series can override how it finds its points, see
custom point finding.
The last argument of GetPointsAt, FindPointFor, tells that override whether the request comes from a hover
(the default) or a press.
Scale pixels to data
ScalePixelsToData converts a position in pixels to the values of the axes, and ScaleDataToPixels does the
opposite. This sample adds a point where the user clicks: it converts the pointer position to data and adds an
ObservablePoint with those coordinates to the values of the series.

@page "/Events/AddPointOnClick"
@using LiveChartsCore.Defaults;
@using LiveChartsCore.Drawing;
@using LiveChartsCore.SkiaSharpView
@using LiveChartsCore.SkiaSharpView.Blazor;
@using LiveChartsCore;
@using System.Collections.ObjectModel;
<CartesianChart
@ref="_chart"
Series="@series"
OnPointerDownCallback="OnPointerDown"
TooltipPosition="LiveChartsCore.Measure.TooltipPosition.Hidden">
</CartesianChart>
@code {
private CartesianChart _chart;
private ObservableCollection<ObservablePoint> _data = new ObservableCollection<ObservablePoint>
{
new ObservablePoint(0, 5),
new ObservablePoint(3, 8),
new ObservablePoint(7, 9)
};
private ISeries[] series;
protected override void OnInitialized()
{
series = new ISeries[]
{
new LineSeries<ObservablePoint>
{
Values = _data,
Fill = null,
DataPadding = new LiveChartsCore.Drawing.LvcPoint(5,5)
}
};
}
private void OnPointerDown(PointerEventArgs e)
{
var p = new LvcPointD(e.OffsetX, e.OffsetY);
var dataCoordinates = _chart.ScalePixelsToData(p);
_data.Add(new ObservablePoint(dataCoordinates.X, dataCoordinates.Y));
}
}
Both methods use the first X and Y axes. With more than one axis, pass the indexes of the axes to use:
var chart = (ICartesianChartView)args.Chart;
var data = chart.ScalePixelsToData(args.PointerPosition, xAxisIndex: 1, yAxisIndex: 0);
var pixels = chart.ScaleDataToPixels(new LvcPointD(5, 5));
The PolarChart has the same two methods, they take the indexes of the angle and radius axes.
Series events
The series events are typed: the points they receive are ChartPoint<TModel, TVisual, TLabel>, where Model is
the data item and Visual the geometry that draws it, so no casts are needed.
DataPointerDown: the pointer went down on points of this series, it receives all of them.ChartPointPointerDown: the pointer went down on points of this series, it receives the closest one.ChartPointPointerHover: the pointer entered a point.ChartPointPointerHoverLost: the pointer left a point.PointCreated: the series created the visual of a point, the first time the point is drawn.PointMeasured: the series calculated the position and size of a point, on every update.
The type of the point depends on the series, the model, the geometry and the label, so let the IDE complete the signature of the handler. In this sample a column turns yellow when the pointer enters it, red when the pointer goes down on it, and gets the paint of the series back when the pointer leaves it:

public class Fruit
{
public string Name { get; set; } = string.Empty;
public double SalesPerDay { get; set; }
}
var series = new ColumnSeries<Fruit>
{
Values = new[]
{
new Fruit { Name = "Apple", SalesPerDay = 4 },
new Fruit { Name = "Orange", SalesPerDay = 6 },
new Fruit { Name = "Pineapple", SalesPerDay = 2 },
new Fruit { Name = "Potato", SalesPerDay = 8 },
new Fruit { Name = "Lettuce", SalesPerDay = 3 },
new Fruit { Name = "Cherry", SalesPerDay = 4 }
},
Mapping = (fruit, index) => new(index, fruit.SalesPerDay),
DataLabelsPaint = new SolidColorPaint(SKColors.Black),
DataLabelsPosition = LiveChartsCore.Measure.DataLabelsPosition.End,
DataLabelsFormatter = point => $"{point.Model!.SalesPerDay} {point.Model.Name}",
YToolTipLabelFormatter = point => $"{point.Model!.Name}, sold {point.Model.SalesPerDay} items"
};
series.ChartPointPointerHover += (chart, point) => // mark
point.Visual!.Fill = new SolidColorPaint(SKColors.Yellow);
series.ChartPointPointerDown += (chart, point) => // mark
point.Visual!.Fill = new SolidColorPaint(SKColors.Red);
series.ChartPointPointerHoverLost += (chart, point) => // mark
point.Visual!.Fill = null;
The extension methods OnPointMeasured, OnPointCreated, OnPointDown, OnPointHover and OnPointHoverLost
subscribe to the same events and return the series, so they can be chained:
var series = new ColumnSeries<Fruit> { /* ... */ }
.OnPointHover((chart, point) => point.Visual!.Fill = new SolidColorPaint(SKColors.Yellow))
.OnPointHoverLost((chart, point) => point.Visual!.Fill = null);
The chart events receive the base ChartPoint type instead, because the Series property of the chart is a
collection of ISeries and the chart does not know their types.
The line series article
uses PointMeasured to rotate each point to a value of its data.
Update events
Measuring, UpdateStarted and UpdateFinished follow each update of the chart. UpdateStarted runs once the
axes and the series are measured, so the scale of the axes is known: the
zooming article uses it
to copy the limits of an axis to another chart, and the
custom drawing article uses it to
place a geometry with ScaleDataToPixels.
chart.UpdateStarted += sender =>
{
var cartesianChart = (ICartesianChartView)sender;
var pixels = cartesianChart.ScaleDataToPixels(new LvcPointD(5, 5));
// ...
};