SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, iOS Chart, Android Chart and JavaScript Chart Components
SciChart Android ships with ~90 Android Chart Examples which you can browse, play with, view the source-code and even export each SciChart Android Chart Example to a stand-alone Android Studio project. All of this is possible with the new and improved SciChart Android Examples Suite, which ships as part of our Android Charts SDK.
Demonstrates the use of the TooltipModifier, part of the ChartModifier API for getting information about Renderable Series and its displaying on tooltips.
Tip!
The SeriesInfo acts as a data-source for the data-point, and each SeriesInfo derived type contains:
– The X,Y values of the series under the cursor.
– The series color.
– The series name.
It can be extended or replaced by a custom SeriesInfo by creating your own SeriesInfoProvider for a Renderable Series.
The full source code for the Android Chart with Tooltips example is included below (Scroll down!).
Did you know you can also view the source code from one of the following sources as well?
//******************************************************************************
// SCICHART® Copyright SciChart Ltd. 2011-2021. All rights reserved.
//
// Web: http://www.scichart.com
// Support: support@scichart.com
// Sales: sales@scichart.com
//
// UsingTooltipModifierTooltipsFragment.kt is part of SCICHART®, High Performance Scientific Charts
// For full terms and conditions of the license, see http://www.scichart.com/scichart-eula/
//
// This source code is protected by international copyright law. Unauthorized
// reproduction, reverse-engineering, or distribution of all or any portion of
// this source code is strictly prohibited.
//
// This source code contains confidential and proprietary trade secrets of
// SciChart Ltd., and should at no time be copied, transferred, sold,
// distributed or made available without express written permission.
//******************************************************************************
package com.scichart.examples.fragments.examples2d.tooltipsAndHitTest.kt
import com.scichart.charting.visuals.SciChartSurface
import com.scichart.charting.visuals.axes.AxisAlignment.Left
import com.scichart.core.model.DoubleValues
import com.scichart.data.model.DoubleRange
import com.scichart.drawing.utility.ColorUtil
import com.scichart.examples.data.DataManager
import com.scichart.examples.fragments.base.ExampleSingleChartBaseFragment
import com.scichart.examples.utils.scichartExtensions.*
class UsingTooltipModifierTooltipsFragment: ExampleSingleChartBaseFragment() {
override fun showDefaultModifiersInToolbar(): Boolean = false
override fun initExample(surface: SciChartSurface) {
val ds1Points = DataManager.getInstance().getLissajousCurve(0.8, 0.2, 0.43, 500)
val ds2Points = DataManager.getInstance().getSinewave(1.5, 1.0, 500)
val scaledXValues = getScaledValues(ds1Points.xValues)
surface.suspendUpdates {
xAxes { numericAxis { growBy = DoubleRange(0.1, 0.1) } }
yAxes { numericAxis { growBy = DoubleRange(0.1, 0.1); axisAlignment = Left } }
renderableSeries {
fastLineRenderableSeries {
xyDataSeries<Double, Double>("Lissajous Curve") {
acceptsUnsortedData = true
append(scaledXValues, ds1Points.yValues)
}
strokeStyle = SolidPenStyle(ColorUtil.SteelBlue)
ellipsePointMarker {
setSize(5)
strokeStyle = SolidPenStyle(ColorUtil.SteelBlue)
fillStyle = SolidBrushStyle(ColorUtil.SteelBlue)
}
opacityAnimation { duration = 1000 }
}
fastLineRenderableSeries {
xyDataSeries<Double, Double>("SineWave") {
acceptsUnsortedData = true
append(ds2Points.xValues, ds2Points.yValues)
}
strokeStyle = SolidPenStyle(0xFFFF3333)
ellipsePointMarker {
setSize(5)
strokeStyle = SolidPenStyle(0xFFFF3333)
fillStyle = SolidBrushStyle(0xFFFF3333)
}
opacityAnimation { duration = 1000 }
}
}
chartModifiers { tooltipModifier() }
}
}
private fun getScaledValues(values: DoubleValues): DoubleValues? {
val result = DoubleValues()
for (value in values.itemsArray) {
result.add((value + 1) * 5)
}
return result
}
}
//******************************************************************************
// SCICHART® Copyright SciChart Ltd. 2011-2021. All rights reserved.
//
// Web: http://www.scichart.com
// Support: support@scichart.com
// Sales: sales@scichart.com
//
// UsingTooltipModifierTooltipsFragment.java is part of SCICHART®, High Performance Scientific Charts
// For full terms and conditions of the license, see http://www.scichart.com/scichart-eula/
//
// This source code is protected by international copyright law. Unauthorized
// reproduction, reverse-engineering, or distribution of all or any portion of
// this source code is strictly prohibited.
//
// This source code contains confidential and proprietary trade secrets of
// SciChart Ltd., and should at no time be copied, transferred, sold,
// distributed or made available without express written permission.
//******************************************************************************
package com.scichart.examples.fragments.examples2d.tooltipsAndHitTest;
import androidx.annotation.NonNull;
import com.scichart.charting.model.dataSeries.XyDataSeries;
import com.scichart.charting.modifiers.TooltipModifier;
import com.scichart.charting.visuals.SciChartSurface;
import com.scichart.charting.visuals.axes.AxisAlignment;
import com.scichart.charting.visuals.axes.IAxis;
import com.scichart.charting.visuals.pointmarkers.EllipsePointMarker;
import com.scichart.charting.visuals.renderableSeries.FastLineRenderableSeries;
import com.scichart.core.framework.UpdateSuspender;
import com.scichart.core.model.DoubleValues;
import com.scichart.drawing.utility.ColorUtil;
import com.scichart.examples.data.DataManager;
import com.scichart.examples.data.DoubleSeries;
import com.scichart.examples.fragments.base.ExampleSingleChartBaseFragment;
import java.util.Collections;
public class UsingTooltipModifierTooltipsFragment extends ExampleSingleChartBaseFragment {
@Override
public boolean showDefaultModifiersInToolbar() {
return false;
}
@Override
protected void initExample(@NonNull SciChartSurface surface) {
final IAxis xAxis = sciChartBuilder.newNumericAxis().withGrowBy(0.1, 0.1).build();
final IAxis yAxis = sciChartBuilder.newNumericAxis().withGrowBy(0.1, 0.1).withAxisAlignment(AxisAlignment.Left).build();
final XyDataSeries<Double, Double> dataSeries1 = sciChartBuilder.newXyDataSeries(Double.class, Double.class).withSeriesName("Lissajous Curve").withAcceptsUnsortedData().build();
final XyDataSeries<Double, Double> dataSeries2 = sciChartBuilder.newXyDataSeries(Double.class, Double.class).withSeriesName("SineWave").withAcceptsUnsortedData().build();
final DoubleSeries ds1Points = DataManager.getInstance().getLissajousCurve(0.8, 0.2, 0.43, 500);
final DoubleSeries ds2Points = DataManager.getInstance().getSinewave(1.5, 1.0, 500);
final DoubleValues scaledXValues = getScaledValues(ds1Points.xValues);
dataSeries1.append(scaledXValues, ds1Points.yValues);
dataSeries2.append(ds2Points.xValues, ds2Points.yValues);
final FastLineRenderableSeries line1 = sciChartBuilder.newLineSeries()
.withStrokeStyle(ColorUtil.SteelBlue, 1f, true)
.withPointMarker(sciChartBuilder.newPointMarker(new EllipsePointMarker()).withSize(5).withStroke(ColorUtil.SteelBlue, 2f).withFill(ColorUtil.SteelBlue).build())
.withDataSeries(dataSeries1)
.build();
final FastLineRenderableSeries line2 = sciChartBuilder.newLineSeries()
.withStrokeStyle(0xFFFF3333, 1f, true)
.withPointMarker(sciChartBuilder.newPointMarker(new EllipsePointMarker()).withSize(5).withStroke(0xFFFF3333, 2f).withFill(0xFFFF3333).build())
.withDataSeries(dataSeries2)
.build();
UpdateSuspender.using(surface, () -> {
Collections.addAll(surface.getXAxes(), xAxis);
Collections.addAll(surface.getYAxes(), yAxis);
Collections.addAll(surface.getRenderableSeries(), line1, line2);
Collections.addAll(surface.getChartModifiers(), new TooltipModifier());
sciChartBuilder.newOpacityAnimator(line1).withDuration(1000).withStartDelay(350).start();
sciChartBuilder.newOpacityAnimator(line2).withDuration(1000).withStartDelay(350).start();
});
}
private DoubleValues getScaledValues(DoubleValues values) {
final DoubleValues result = new DoubleValues();
for (double value : values.getItemsArray()) {
result.add((value + 1) * 5);
}
return result;
}
}