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 Zoom, Pan and Rotate the 3D chart created with Xamarin.iOS and Xamarin.Android.
See more in the documentation:Create a 3D Chart with Xamarin.Android Create a 3D Chart with Xamarin.iOS Chart Modifiers in SciChart Android Chart Modifiers in SciChart iOS
The C#/Xamarin.iOS/Xamarin.Android source code for the Xamarin Create Free Surface Chart 3D Chart 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 Xamarin.Examples.Demo.Data;
using SciChart.iOS.Charting;
using Xamarin.Examples.Demo.Utils;
using UIKit;
namespace Xamarin.Examples.Demo.iOS
{
class ButtonsPanel : UIView
{
public UIButton rotateHorizontal { get; } = new UIButton(UIButtonType.System) { TranslatesAutoresizingMaskIntoConstraints = false };
public UIButton rotateVertical { get; } = new UIButton(UIButtonType.System) { TranslatesAutoresizingMaskIntoConstraints = false };
public ButtonsPanel()
{
rotateHorizontal.SetTitle("Rotate Horizontal", UIControlState.Normal);
rotateVertical.SetTitle("Rotate Vertical", UIControlState.Normal);
AddSubviews(rotateHorizontal, rotateVertical);
rotateHorizontal.LeadingAnchor.ConstraintEqualTo(LeadingAnchor, 8).Active = true;
rotateHorizontal.TopAnchor.ConstraintEqualTo(TopAnchor, 8).Active = true;
rotateHorizontal.BottomAnchor.ConstraintEqualTo(BottomAnchor, -8).Active = true;
rotateHorizontal.TrailingAnchor.ConstraintEqualTo(rotateVertical.LeadingAnchor, -8).Active = true;
rotateVertical.TopAnchor.ConstraintEqualTo(TopAnchor, 8).Active = true;
rotateVertical.BottomAnchor.ConstraintEqualTo(BottomAnchor, -8).Active = true;
rotateVertical.TrailingAnchor.ConstraintEqualTo(TrailingAnchor, 8).Active = true;
rotateHorizontal.WidthAnchor.ConstraintEqualTo(rotateVertical.WidthAnchor).Active = true;
}
}
[Example3DDefinition("Use Chart Modifiers 3D", description: "Demonstrates PinchZoomModifier3D, OrbitModifier3D and ZoomExtentsModifier3D", icon: ExampleIcon.ZoomPan)]
class UseChartModifiers3DViewController : SingleChartWithTopPanelViewController<SCIChartSurface3D>
{
public override UIView ProvidePanel()
{
var panel = new ButtonsPanel();
panel.rotateHorizontal.TouchUpInside += (sender, args) =>
{
var yaw = Surface.Camera.OrbitalYaw;
Surface.Camera.OrbitalYaw = yaw < 360 ? yaw + 90 : 360 - yaw;
};
panel.rotateVertical.TouchUpInside += (sender, args) =>
{
var pitch = Surface.Camera.OrbitalPitch;
Surface.Camera.OrbitalPitch = pitch < 89 ? pitch + 90 : -90;
};
return panel;
}
protected override void InitExample()
{
const int count = 25;
var dataManager = DataManager.Instance;
var dataSeries3D = new XyzDataSeries3D<double, double, double>();
var metadataProvider = new SCIPointMetadataProvider3D();
for (int x = 0; x < count; x++)
{
var color = dataManager.GetRandomColor();
for (int z = 1; z < count; z++)
{
var y = Math.Pow(z, 0.3);
dataSeries3D.Append(x, y, z);
var metadata = new SCIPointMetadata3D((uint)color.ToArgb(), 2);
metadataProvider.Metadata.Add(metadata);
}
}
var renderableSeries3D = new SCIScatterRenderableSeries3D
{
DataSeries = dataSeries3D,
MetadataProvider = metadataProvider,
PointMarker = new SCISpherePointMarker3D { FillColor = ColorUtil.Lime, Size = 5f },
};
using (Surface.SuspendUpdates())
{
Surface.XAxis = new SCINumericAxis3D { GrowBy = new SCIDoubleRange(0.1, 0.1) };
Surface.YAxis = new SCINumericAxis3D { GrowBy = new SCIDoubleRange(0.1, 0.1) };
Surface.ZAxis = new SCINumericAxis3D { GrowBy = new SCIDoubleRange(0.1, 0.1) };
Surface.RenderableSeries.Add(renderableSeries3D);
Surface.ChartModifiers.Add(CreateDefault3DModifiers());
Surface.Camera = new SCICamera3D();
}
}
}
}
using Android.Widget;
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.Scatter;
using SciChart.Data.Model;
using Xamarin.Examples.Demo.Data;
using Xamarin.Examples.Demo;
using System;
using System.Drawing;
using Xamarin.Examples.Demo.Droid.Components;
using Xamarin.Examples.Demo.Droid.Fragments.Base;
namespace Xamarin.Examples.Demo.Droid.Fragments.Examples3D
{
[Example3DDefinition("Use Chart Modifiers 3D", description: "Demonstrates PinchZoomModifier3D, OrbitModifier3D and ZoomExtentsModifier3D", icon: ExampleIcon.ZoomPan)]
class UseChartModifiers3DFragment : ExampleBaseFragment
{
public SciChartSurface3D Surface => View.FindViewById<SciChartSurface3D>(Resource.Id.chart3d);
public override int ExampleLayoutId => Resource.Layout.Example_Chart3D_Modifiers_Fragment;
protected override void InitExample()
{
View.FindViewById<Button>(Resource.Id.rotateHorizontal).Click += (sender, args) =>
{
var yaw = Surface.Camera.OrbitalYaw;
if(yaw < 360)
{
Surface.Camera.OrbitalYaw = yaw + 90;
}
else
{
Surface.Camera.OrbitalYaw = 360 - yaw;
}
};
View.FindViewById<Button>(Resource.Id.rotateVertical).Click += (sender, args) =>
{
var pitch = Surface.Camera.OrbitalPitch;
if (pitch < 89)
{
Surface.Camera.OrbitalPitch = pitch + 90;
}
else
{
Surface.Camera.OrbitalPitch = -90;
}
};
const int count = 25;
var dataManager = DataManager.Instance;
var dataSeries3D = new XyzDataSeries3D<double, double, double>();
var metadataProvider = new PointMetadataProvider3D();
for (int x = 0; x < count; x++)
{
var color = dataManager.GetRandomColor();
for (int z = 1; z < count; z++)
{
var y = Math.Pow(z, 0.3);
dataSeries3D.Append(x, y, z);
metadataProvider.Metadata.Add(new PointMetadata3D(color, 2));
}
}
var pointMarker3D = new SpherePointMarker3D()
{
FillColor = Color.Lime,
Size = 5f
};
var renderableSeries3D = new ScatterRenderableSeries3D()
{
PointMarker = pointMarker3D,
DataSeries = dataSeries3D,
MetadataProvider = metadataProvider
};
using (Surface.SuspendUpdates())
{
Surface.XAxis = new NumericAxis3D() { GrowBy = new DoubleRange(0.1, 0.1) };
Surface.YAxis = new NumericAxis3D() { GrowBy = new DoubleRange(0.1, 0.1) };
Surface.ZAxis = new NumericAxis3D() { GrowBy = new DoubleRange(0.1, 0.1) };
Surface.Camera = new Camera3D();
Surface.RenderableSeries.Add(renderableSeries3D);
Surface.ChartModifiers = new ChartModifier3DCollection
{
new PinchZoomModifier3D(),
new OrbitModifier3D(),
new ZoomExtentsModifier3D()
};
}
}
}
}