SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, iOS Chart, Android Chart and JavaScript Chart Components
Please note! These examples are new to SciChart Mobile v3 release! SciChart iOS & Android ship with Xamarin.iOS and Xamarin.Android bindings around our native iOS & Android Chart controls, allowing you to create fast & feature rich charts to your Xamarin applications. We include ~90 native iOS examples and 90 Android examples, but now also ~60 Xamarin Chart Examples to help you get started with SciChart. You can download the source for our Xamarin Chart Examples from Github, or browse the source code below.
This example demonstrates how to addtooltips to a series in SciChart Xamarin.
Learn more in our articles and documentation on Tooltips and Cursors: Cursors and Tooltips in Xamarin.iOS 3D Cursors and Tooltips in Xamarin.Android 3D
The C#/Xamarin.iOS/Xamarin.Android source code for the Xamarin Series Tooltips 3D example is included below (Scroll down!).
Did you know you can also view the source code from one of the following sources as well?
using System;
using SciChart.iOS.Charting;
namespace Xamarin.Examples.Demo.iOS
{
[Example3DDefinition("Series Tooltips 3D Chart", description: "Add Tooltips on a 3D Chart", icon: ExampleIcon.LineChart)]
class SeriesTooltips3DChartViewController : SingleChartWithModifierTipViewController<SCIChartSurface3D>
{
private readonly double CosYAngle = Math.Cos(-65d.ToRadians());
private readonly double SinYAngle = Math.Sin(-65d.ToRadians());
public override string ModifierTip => "To rotate chart use scroll with two fingers";
protected override void InitExample()
{
const int segmentsCount = 25;
var blueColor = 0xFF0084CF;
var redColor = 0xFFEE1110;
var rotationAngle = 360 / 45d;
var dataSeries3D = new XyzDataSeries3D<double, double, double>();
var metadataProvider = new SCIPointMetadataProvider3D();
var currentAngle = 0d;
for (int i = -segmentsCount; i < segmentsCount + 1; i++)
{
AppendPoint(dataSeries3D, -4, i, currentAngle);
AppendPoint(dataSeries3D, 4, i, currentAngle);
metadataProvider.Metadata.Add(new SCIPointMetadata3D(redColor));
metadataProvider.Metadata.Add(new SCIPointMetadata3D(blueColor));
currentAngle = (currentAngle + rotationAngle) % 360;
}
var rSeries3D = new SCIPointLineRenderableSeries3D
{
DataSeries = dataSeries3D,
PointMarker = new SCISpherePointMarker3D { Size = 8f },
MetadataProvider = metadataProvider,
IsLineStrips = false,
StrokeThickness = 4f,
};
using (Surface.SuspendUpdates())
{
Surface.XAxis = new SCINumericAxis3D { GrowBy = new SCIDoubleRange(0.2, 0.2), MaxAutoTicks = 5 };
Surface.YAxis = new SCINumericAxis3D { GrowBy = new SCIDoubleRange(0.1, 0.1) };
Surface.ZAxis = new SCINumericAxis3D { GrowBy = new SCIDoubleRange(0.2, 0.2) };
Surface.RenderableSeries.Add(rSeries3D);
Surface.ChartModifiers = new SCIChartModifier3DCollection
{
new SCIPinchZoomModifier3D(),
new SCIOrbitModifier3D(defaultNumberOfTouches: 2) { ReceiveHandledEvents = true },
new SCIZoomExtentsModifier3D(),
new SCITooltipModifier3D
{
CrosshairMode = SCICrosshairMode.Lines,
CrosshairPlanesFill = 0x33FF6600.ToUIColor(),
ReceiveHandledEvents = true,
ExecuteOnPointerCount = 1
}
};
Surface.Camera = new SCICamera3D { Position = new SCIVector3(-160, 190, -520), Target = new SCIVector3(-45, 150, 0) };
Surface.WorldDimensions = new SCIVector3(600, 300, 180);
}
}
private void AppendPoint(XyzDataSeries3D<double, double, double> ds, double x, double y, double currentAngle)
{
var radAngle = currentAngle.ToRadians();
var temp = x * Math.Cos(radAngle);
var xValue = temp * CosYAngle - y * SinYAngle;
var yValue = temp * SinYAngle + y * CosYAngle;
var zValue = x * Math.Sin(radAngle);
ds.Append(xValue, yValue, zValue);
}
}
}
using Java.Lang;
using SciChart.Charting3D.Common.Math;
using SciChart.Charting3D.Model;
using SciChart.Charting3D.Model.DataSeries.Xyz;
using SciChart.Charting3D.Modifiers;
using SciChart.Charting3D.Visuals;
using SciChart.Charting3D.Visuals.Axes;
using SciChart.Charting3D.Visuals.Camera;
using SciChart.Charting3D.Visuals.PointMarkers;
using SciChart.Charting3D.Visuals.RenderableSeries.PointLine;
using SciChart.Data.Model;
using Xamarin.Examples.Demo;
using System.Drawing;
using Xamarin.Examples.Demo.Droid.Components;
using Xamarin.Examples.Demo.Droid.Extensions;
using Xamarin.Examples.Demo.Droid.Fragments.Base;
namespace Xamarin.Examples.Demo.Droid.Fragments.Examples3D
{
[Example3DDefinition("Series Tooltips 3D Chart", description: "Add Tooltips on a 3D Chart", icon: ExampleIcon.LineChart)]
class SeriesTooltips3DChartFragment : ExampleBaseFragment
{
private readonly double CosYAngle = Math.Cos(Math.ToRadians(-65));
private readonly double SinYAngle = Math.Sin(Math.ToRadians(-65));
public SciChartSurface3D Surface => View.FindViewById<SciChartSurface3D>(Resource.Id.chart3d);
public override int ExampleLayoutId => Resource.Layout.Example_Single_3D_Chart_With_Modifier_Tip_Fragment;
protected override void InitExample()
{
const int segmentsCount = 25;
var blueColor = Color.FromArgb(0, 0x84, 0xCF);
var redColor = Color.FromArgb(0xEE, 0x11, 0x10);
var rotationAngle = 360 / 45d;
var dataSeries3D = new XyzDataSeries3D<double, double, double>();
var metadataProvider = new PointMetadataProvider3D();
var currentAngle = 0d;
for (int i = -segmentsCount; i < segmentsCount + 1; i++)
{
AppendPoint(dataSeries3D, -4, i, currentAngle);
AppendPoint(dataSeries3D, 4, i, currentAngle);
metadataProvider.Metadata.Add(new PointMetadata3D(redColor));
metadataProvider.Metadata.Add(new PointMetadata3D(blueColor));
currentAngle = (currentAngle + rotationAngle) % 360;
}
var pointMarker3D = new SpherePointMarker3D()
{
Size = 8f
};
var renderableSeries3D = new PointLineRenderableSeries3D()
{
PointMarker = pointMarker3D,
DataSeries = dataSeries3D,
MetadataProvider = metadataProvider,
IsLineStrips = false,
StrokeThickness = 4f.ToDip(Activity)
};
using (Surface.SuspendUpdates())
{
Surface.WorldDimensions.Assign(600, 300, 180);
Surface.XAxis = new NumericAxis3D() { GrowBy = new DoubleRange(0.2, 0.2) };
Surface.YAxis = new NumericAxis3D() { GrowBy = new DoubleRange(0.1, 0.1) };
Surface.ZAxis = new NumericAxis3D() { VisibleRange = new DoubleRange(-9, 9) };
Surface.Camera = new Camera3D()
{
Position = new Vector3(-160, 190, -520),
Target = new Vector3(-45, 150, 0),
ZoomToFitOnAttach = false
};
Surface.RenderableSeries.Add(renderableSeries3D);
Surface.ChartModifiers = new ChartModifier3DCollection
{
new PinchZoomModifier3D(),
new OrbitModifier3D() { ReceiveHandledEvents = true, ExecuteOnPointerCount = 2 },
new ZoomExtentsModifier3D(),
new TooltipModifier3D()
{
CrosshairMode = CrosshairMode.Lines,
CrosshairPlanesFill = 0x33FF6600,
ReceiveHandledEvents = true,
ExecuteOnPointerCount = 1
}
};
}
}
private void AppendPoint(XyzDataSeries3D<double, double, double> ds, double x, double y, double currentAngle)
{
var radAngle = Math.ToRadians(currentAngle);
var temp = x * Math.Cos(radAngle);
var xValue = temp * CosYAngle - y * SinYAngle;
var yValue = temp * SinYAngle + y * CosYAngle;
var zValue = x * Math.Sin(radAngle);
ds.Append(xValue, yValue, zValue);
}
}
}