Android & Xamarin.Android Charting Documentation - SciChart Android Charts SDK v2.x
Xamarin Tutorial 05 - Adding Tooltips & Legends to a Chart

This article is a continuation of a tutorial series on how to create a chart using SciChart Xamarin.Android. So far we have created a new chart, added both X axis and Y axis, some series with data and also zoom and pan behaviors. The previous tutorial can be found here: Xamarin Tutorial 04 - Adding Zooming, Panning Behavior.

Adding a Legend to the Chart

In SciChart, a chart legend can be created and configured via the LegendModifier:

Create a LegendModifier
Copy Code
// Create and configure legend
var legendModifier = new LegendModifier(this);
legendModifier.SetLegendPosition(GravityFlags.Bottom | GravityFlags.CenterHorizontal, 10);

Adding Series Tooltips

Similarly, to add series tooltips you have to create a corresponding modifier and add it to the ChartModifiers collection of a SciChartSurface. In this tutorial, we are going to add a RolloverModifier to the chart:

Create a RolloverModifier
Copy Code
// Create RolloverModifier to show tooltips
var rolloverModifier = new RolloverModifier();

The last step is to modify previosly created ModifierGroup and add new modifiers:

Add new modifiers
Copy Code
var modifiers = new ModifierGroup(pinchZoomModifier, zoomPanModifier, zoomExtentsModifier, yAxisDragModifier, rolloverModifier, legendModifier);

When you rebuild project you should see next:

See Also