Tutorial 05 - Adding Tooltips and Legends
This follows Tutorial 04 - Adding Zooming, Panning Behavior.So far we have created a new chart, added both X axis and Y axis, plotted data series, and added zoom and pan. Now we will add a chart legend and tool tips.
Source code for this tutorial can be found at SciChart.Android.Examples Github Repository
Add a Legend
In SciChart, a chart legend can be created and configured via the LegendModifier:
Copy Code | |
---|---|
// Create a LegendModifier and configure a chart legend ModifierGroup legendModifier = sciChartBuilder.newModifierGroup() .withLegendModifier() .withOrientation(Orientation.HORIZONTAL) .withPosition(Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM, 10) .build() .build(); // Add the LegendModifier to the SciChartSurface surface.getChartModifiers().add(legendModifier); |
Add a Cursor (Crosshair)
CursorModifier adds a crosshair onto a SciChartSurface. When you put your finger on the screen or otherwise click it, it shows series values in tooltips and chart coordinates at that point point.
Example Title |
Copy Code |
---|---|
// Create and configure a CursorModifier ModifierGroup cursorModifier = sciChartBuilder.newModifierGroup() .withCursorModifier().withShowTooltip(true).build() .build(); // Add the CursorModifier to the SciChartSurface surface.getChartModifiers().add(cursorModifier); |
Further Reading
To learn more about cursors and legends in SciChart please find links to the corresponding documentation articles below:
See Also