protected XYMultipleSeriesDataset BuildDataset(String[] titles, IList <double[]> xValues, IList <double[]> yValues) { XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset(); AddXYSeries(dataset, titles, xValues, yValues, 0); return(dataset); }
/// <summary> /// Builds an XY multiple dataset using the provided values. /// </summary> /// <param name="titles"> the series titles </param> /// <param name="xValues"> the values for the X axis </param> /// <param name="yValues"> the values for the Y axis </param> /// <returns> the XY multiple dataset </returns> protected internal virtual XYMultipleSeriesDataset buildDataset(string[] titles, IList <double[]> xValues, IList <double[]> yValues) { XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset(); addXYSeries(dataset, titles, xValues, yValues, 0); return(dataset); }
protected override void OnRestoreInstanceState(Android.OS.Bundle savedInstanceState) { base.OnRestoreInstanceState(savedInstanceState); mDataset = savedInstanceState.GetSerializable("dataset") as XYMultipleSeriesDataset; mRenderer = savedInstanceState.GetSerializable("renderer") as XYMultipleSeriesRenderer; mCurrentSeries = savedInstanceState.GetSerializable("current_series") as XYSeries; mCurrentRenderer = savedInstanceState.GetSerializable("current_renderer") as XYSeriesRenderer; }
protected override void OnRestoreInstanceState(Bundle savedState) { base.OnRestoreInstanceState(savedState); // restore the current data, for instance when changing the screen // orientation mDataset = (XYMultipleSeriesDataset)savedState.GetSerializable("dataset"); mRenderer = (XYMultipleSeriesRenderer)savedState.GetSerializable("renderer"); mCurrentSeries = (XYSeries)savedState.GetSerializable("current_series"); mCurrentRenderer = (XYSeriesRenderer)savedState.GetSerializable("current_renderer"); }
/// <summary> /// Executes the chart demo. /// </summary> /// <param name="context"> the context </param> /// <returns> the built intent </returns> public override Intent execute(Context context) { string[] titles = new string[] { "Air temperature" }; IList <double[]> x = new List <double[]>(); for (int i = 0; i < titles.Length; i++) { x.Add(new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }); } IList <double[]> values = new List <double[]>(); values.Add(new double[] { 12.3, 12.5, 13.8, 16.8, 20.4, 24.4, 26.4, 26.1, 23.6, 20.3, 17.2, 13.9 }); int[] colors = new int[] { Color.BLUE, Color.YELLOW }; PointStyle[] styles = new PointStyle[] { PointStyle.POINT, PointStyle.POINT }; XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer(2); setRenderer(renderer, colors, styles); int length = renderer.SeriesRendererCount; for (int i = 0; i < length; i++) { XYSeriesRenderer r = (XYSeriesRenderer)renderer.getSeriesRendererAt(i); r.LineWidth = 3f; } setChartSettings(renderer, "Average temperature", "Month", "Temperature", 0.5, 12.5, 0, 32, Color.LTGRAY, Color.LTGRAY); renderer.XLabels = 12; renderer.YLabels = 10; renderer.ShowGrid = true; renderer.XLabelsAlign = Align.RIGHT; renderer.YLabelsAlign = Align.RIGHT; renderer.ZoomButtonsVisible = true; renderer.PanLimits = new double[] { -10, 20, -10, 40 }; renderer.ZoomLimits = new double[] { -10, 20, -10, 40 }; renderer.ZoomRate = 1.05f; renderer.LabelsColor = Color.WHITE; renderer.XLabelsColor = Color.GREEN; renderer.setYLabelsColor(0, colors[0]); renderer.setYLabelsColor(1, colors[1]); renderer.setYTitle("Hours", 1); renderer.setYAxisAlign(Align.RIGHT, 1); renderer.setYLabelsAlign(Align.LEFT, 1); XYMultipleSeriesDataset dataset = buildDataset(titles, x, values); values.Clear(); values.Add(new double[] { 4.3, 4.9, 5.9, 8.8, 10.8, 11.9, 13.6, 12.8, 11.4, 9.5, 7.5, 5.5 }); addXYSeries(dataset, new string[] { "Sunshine hours" }, x, values, 1); Intent intent = ChartFactory.getCubicLineChartIntent(context, dataset, renderer, 0.3f, "Average temperature"); return(intent); }
/// <summary> /// Executes the chart demo. /// </summary> /// <param name="context"> the context </param> /// <returns> the built intent </returns> public override Intent Execute(Context context) { string[] titles = new string[] { "Air temperature" }; IList <double[]> x = new List <double[]>(); for (int i = 0; i < titles.Length; i++) { x.Add(new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }); } IList <double[]> values = new List <double[]>(); values.Add(new double[] { 12.3, 12.5, 13.8, 16.8, 20.4, 24.4, 26.4, 26.1, 23.6, 20.3, 17.2, 13.9 }); int[] colors = new int[] { Color.Blue, Color.Yellow }; PointStyle[] styles = new PointStyle[] { PointStyle.Point, PointStyle.Point }; XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer(2); SetRenderer(renderer, colors, styles); int length = renderer.SeriesRendererCount; for (int i = 0; i < length; i++) { XYSeriesRenderer r = (XYSeriesRenderer)renderer.GetSeriesRendererAt(i); r.LineWidth = 3f; } SetChartSettings(renderer, "Average temperature", "Month", "Temperature", 0.5, 12.5, 0, 32, Color.LightGray, Color.LightGray); renderer.XLabels = 12; renderer.YLabels = 10; renderer.SetShowGrid(true); renderer.XLabelsAlign = Android.Graphics.Paint.Align.Right; renderer.SetYLabelsAlign(Android.Graphics.Paint.Align.Right); renderer.ZoomButtonsVisible = true; renderer.SetPanLimits(new double[] { -10, 20, -10, 40 }); renderer.SetZoomLimits(new double[] { -10, 20, -10, 40 }); renderer.ZoomRate = 1.05f; renderer.LabelsColor = Color.White; renderer.XLabelsColor = Color.Green; renderer.SetYLabelsColor(0, colors[0]); renderer.SetYLabelsColor(1, colors[1]); renderer.SetYTitle("Hours", 1); renderer.SetYAxisAlign(Android.Graphics.Paint.Align.Right, 1); renderer.SetYLabelsAlign(Android.Graphics.Paint.Align.Left, 1); XYMultipleSeriesDataset dataset = BuildDataset(titles, x, values); values.Clear(); values.Add(new double[] { 4.3, 4.9, 5.9, 8.8, 10.8, 11.9, 13.6, 12.8, 11.4, 9.5, 7.5, 5.5 }); AddXYSeries(dataset, new string[] { "Sunshine hours" }, x, values, 1); Intent intent = ChartFactory.GetCubicLineChartIntent(context, dataset, renderer, 0.3f, "Average temperature"); return(intent); }
public virtual void addXYSeries(XYMultipleSeriesDataset dataset, string[] titles, IList<double[]> xValues, IList<double[]> yValues, int scale) { int length = titles.Length; for (int i = 0; i < length; i++) { XYSeries series = new XYSeries(titles[i], scale); double[] xV = xValues[i]; double[] yV = yValues[i]; int seriesLength = xV.Length; for (int k = 0; k < seriesLength; k++) { series.add(xV[k], yV[k]); } dataset.addSeries(series); } }
public virtual void addXYSeries(XYMultipleSeriesDataset dataset, string[] titles, IList <double[]> xValues, IList <double[]> yValues, int scale) { int length = titles.Length; for (int i = 0; i < length; i++) { XYSeries series = new XYSeries(titles[i], scale); double[] xV = xValues[i]; double[] yV = yValues[i]; int seriesLength = xV.Length; for (int k = 0; k < seriesLength; k++) { series.add(xV[k], yV[k]); } dataset.addSeries(series); } }
public void AddXYSeries(XYMultipleSeriesDataset dataset, String[] titles, IList <double[]> xValues, IList <double[]> yValues, int scale) { int length = titles.Length; for (int i = 0; i < length; i++) { XYSeries series = new XYSeries(titles[i], scale); double[] xV = xValues[i]; double[] yV = yValues[i]; int seriesLength = xV.Length; for (int j = 0; j < seriesLength; j++) { series.Add(xV[j], yV[j]); } dataset.AddSeries(series); } }
private XYMultipleSeriesDataset GetBarDemoDataset() { XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset(); const int nr = 10; Random r = new Random(); for (int i = 0; i < SERIES_NR; i++) { CategorySeries series = new CategorySeries("Demo series " + (i + 1)); for (int k = 0; k < nr; k++) { series.Add(100 + r.Next() % 100); } dataset.AddSeries(series.ToXYSeries()); } return(dataset); }
/// <summary> /// Builds a bar multiple series dataset using the provided values. /// </summary> /// <param name="titles"> the series titles </param> /// <param name="values"> the values </param> /// <returns> the XY multiple bar dataset </returns> protected internal virtual XYMultipleSeriesDataset buildBarDataset(string[] titles, IList <double[]> values) { XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset(); int length = titles.Length; for (int i = 0; i < length; i++) { CategorySeries series = new CategorySeries(titles[i]); double[] v = values[i]; int seriesLength = v.Length; for (int k = 0; k < seriesLength; k++) { series.add(v[k]); } dataset.addSeries(series.toXYSeries()); } return(dataset); }
private XYMultipleSeriesDataset GetDateDemoDataset() { XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset(); const int nr = 10; long value = new Java.Util.Date().Time - 3 * TimeChart.Day; Random r = new Random(); for (int i = 0; i < SERIES_NR; i++) { TimeSeries series = new TimeSeries("Demo series " + (i + 1)); for (int k = 0; k < nr; k++) { series.Add(new Java.Util.Date(value + k * TimeChart.Day / 4), 20 + r.Next() % 100); } dataset.AddSeries(series); } return(dataset); }
protected XYMultipleSeriesDataset BuildBarDataset(String[] title, IList <double[]> values) { XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset(); int length = title.Length; for (int i = 0; i < length; i++) { CategorySeries series = new CategorySeries(title[i]); double[] v = values[i]; int seriesLength = v.Length; for (int k = 0; k < seriesLength; k++) { series.Add(v[k]); } dataset.AddSeries(series.ToXYSeries()); } return(dataset); }
/// <summary> /// Builds an XY multiple time dataset using the provided values. /// </summary> /// <param name="titles"> the series titles </param> /// <param name="xValues"> the values for the X axis </param> /// <param name="yValues"> the values for the Y axis </param> /// <returns> the XY multiple time dataset </returns> protected internal virtual XYMultipleSeriesDataset BuildDateDataset(string[] titles, IList <Java.Util.Date[]> xValues, IList <double[]> yValues) { XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset(); int length = titles.Length; for (int i = 0; i < length; i++) { TimeSeries series = new TimeSeries(titles[i]); Java.Util.Date[] xV = xValues[i]; double[] yV = yValues[i]; int seriesLength = xV.Length; for (int k = 0; k < seriesLength; k++) { series.Add(xV[k], yV[k]); } dataset.AddSeries(series); } return(dataset); }
public override Android.Content.Intent Execute(Android.Content.Context context) { double[] minValues = new double[] { -24, -19, -10, -1, 7, 12, 15, 14, 9, 1, -11, -16 }; double[] maxValues = new double[] { 7, 12, 24, 28, 33, 35, 37, 36, 28, 19, 11, 4 }; XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset(); RangeCategorySeries series = new RangeCategorySeries("Temperature"); int length = minValues.Length; for (int k = 0; k < length; k++) { series.Add(minValues[k], maxValues[k]); } dataset.AddSeries(series.ToXYSeries()); int[] colors = new int[] { Color.Cyan }; XYMultipleSeriesRenderer renderer = BuildBarRenderer(colors); SetChartSettings(renderer, "Monthly temperature range", "Month", "Celsius degrees", 0.5, 12.5, -30, 45, Color.Gray, Color.LightGray); renderer.BarSpacing = 0.5; renderer.XLabels = 0; renderer.YLabels = 10; renderer.AddXTextLabel(1, "Jan"); renderer.AddXTextLabel(3, "Mar"); renderer.AddXTextLabel(5, "May"); renderer.AddXTextLabel(7, "Jul"); renderer.AddXTextLabel(10, "Oct"); renderer.AddXTextLabel(12, "Dec"); renderer.AddYTextLabel(-25, "Very cold"); renderer.AddYTextLabel(-10, "Cold"); renderer.AddYTextLabel(5, "OK"); renderer.AddYTextLabel(20, "Noci"); renderer.SetMargins(new int[] { 30, 70, 10, 0 }); renderer.SetYLabelsAlign(Android.Graphics.Paint.Align.Right); SimpleSeriesRenderer r = renderer.GetSeriesRendererAt(0); r.DisplayChartValues = true; r.ChartValuesTextSize = 12; r.ChartValuesSpacing = 3; r.GradientEnabled = true; r.SetGradientStart(-20, Color.Blue); r.SetGradientStop(20, Color.Green); return(ChartFactory.GetRangeBarChartIntent(context, dataset, renderer, BarChart.Type.Default, "Temperatur range")); }
protected XYMultipleSeriesDataset BuildDateDataset(String[] titles, IList <Date[]> xValues, IList <double[]> yValues) { XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset(); int length = titles.Length; for (int i = 0; i < length; i++) { TimeSeries series = new TimeSeries(titles[i]); Date[] xV = xValues[i]; double[] yV = yValues[i]; int seriesLength = xV.Length; for (int j = 0; j < seriesLength; j++) { series.Add(xV[j], yV[j]); } dataset.AddSeries(series); } return(dataset); }
/// <summary> /// Executes the chart demo. /// </summary> /// <param name="context"> the context </param> /// <returns> the built intent </returns> public override Intent execute(Context context) { string[] titles = new string[] { "Crete", "Corfu", "Thassos", "Skiathos" }; IList <double[]> x = new List <double[]>(); for (int i = 0; i < titles.Length; i++) { x.Add(new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }); } IList <double[]> values = new List <double[]>(); values.Add(new double[] { 12.3, 12.5, 13.8, 16.8, 20.4, 24.4, 26.4, 26.1, 23.6, 20.3, 17.2, 13.9 }); values.Add(new double[] { 10, 10, 12, 15, 20, 24, 26, 26, 23, 18, 14, 11 }); values.Add(new double[] { 5, 5.3, 8, 12, 17, 22, 24.2, 24, 19, 15, 9, 6 }); values.Add(new double[] { 9, 10, 11, 15, 19, 23, 26, 25, 22, 18, 13, 10 }); int[] colors = new int[] { Color.BLUE, Color.GREEN, Color.CYAN, Color.YELLOW }; PointStyle[] styles = new PointStyle[] { PointStyle.CIRCLE, PointStyle.DIAMOND, PointStyle.TRIANGLE, PointStyle.SQUARE }; XYMultipleSeriesRenderer renderer = buildRenderer(colors, styles); int length = renderer.SeriesRendererCount; for (int i = 0; i < length; i++) { ((XYSeriesRenderer)renderer.getSeriesRendererAt(i)).FillPoints = true; } setChartSettings(renderer, "Average temperature", "Month", "Temperature", 0.5, 12.5, -10, 40, Color.LTGRAY, Color.LTGRAY); renderer.XLabels = 12; renderer.YLabels = 10; renderer.ShowGrid = true; renderer.XLabelsAlign = Align.RIGHT; renderer.YLabelsAlign = Align.RIGHT; renderer.ZoomButtonsVisible = true; renderer.PanLimits = new double[] { -10, 20, -10, 40 }; renderer.ZoomLimits = new double[] { -10, 20, -10, 40 }; XYMultipleSeriesDataset dataset = buildDataset(titles, x, values); XYSeries series = dataset.getSeriesAt(0); series.addAnnotation("Vacation", 6, 30); Intent intent = ChartFactory.getLineChartIntent(context, dataset, renderer, "Average temperature"); return(intent); }
/// <summary> /// Executes the chart demo. /// </summary> /// <param name="context"> the context </param> /// <returns> the built intent </returns> public override Intent Execute(Context context) { XYMultipleSeriesDataset series = new XYMultipleSeriesDataset(); XYValueSeries newTicketSeries = new XYValueSeries("New Tickets"); newTicketSeries.Add(1f, 2, 14); newTicketSeries.Add(2f, 2, 12); newTicketSeries.Add(3f, 2, 18); newTicketSeries.Add(4f, 2, 5); newTicketSeries.Add(5f, 2, 1); series.AddSeries(newTicketSeries); XYValueSeries fixedTicketSeries = new XYValueSeries("Fixed Tickets"); fixedTicketSeries.Add(1f, 1, 7); fixedTicketSeries.Add(2f, 1, 4); fixedTicketSeries.Add(3f, 1, 18); fixedTicketSeries.Add(4f, 1, 3); fixedTicketSeries.Add(5f, 1, 1); series.AddSeries(fixedTicketSeries); XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer(); renderer.AxisTitleTextSize = 16; renderer.ChartTitleTextSize = 20; renderer.LabelsTextSize = 15; renderer.LegendTextSize = 15; renderer.SetMargins(new int[] { 20, 30, 15, 0 }); XYSeriesRenderer newTicketRenderer = new XYSeriesRenderer(); newTicketRenderer.Color = Color.Blue; renderer.AddSeriesRenderer(newTicketRenderer); XYSeriesRenderer fixedTicketRenderer = new XYSeriesRenderer(); fixedTicketRenderer.Color = Color.Green; renderer.AddSeriesRenderer(fixedTicketRenderer); SetChartSettings(renderer, "Project work status", "Priority", "", 0.5, 5.5, 0, 5, Color.Gray, Color.LightGray); renderer.XLabels = 7; renderer.YLabels = 0; renderer.SetShowGrid(false); return(ChartFactory.GetBubbleChartIntent(context, series, renderer, "Project tickets")); }
/// <summary> /// Executes the chart demo. /// </summary> /// <param name="context"> the context </param> /// <returns> the built intent </returns> public override Intent Execute(Context context) { string[] titles = new string[] { "Crete", "Corfu", "Thassos", "Skiathos" }; IList <double[]> x = new List <double[]>(); for (int i = 0; i < titles.Length; i++) { x.Add(new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }); } IList <double[]> values = new List <double[]>(); values.Add(new double[] { 12.3, 12.5, 13.8, 16.8, 20.4, 24.4, 26.4, 26.1, 23.6, 20.3, 17.2, 13.9 }); values.Add(new double[] { 10, 10, 12, 15, 20, 24, 26, 26, 23, 18, 14, 11 }); values.Add(new double[] { 5, 5.3, 8, 12, 17, 22, 24.2, 24, 19, 15, 9, 6 }); values.Add(new double[] { 9, 10, 11, 15, 19, 23, 26, 25, 22, 18, 13, 10 }); int[] colors = new int[] { Color.Blue, Color.Green, Color.Cyan, Color.Yellow }; PointStyle[] styles = new PointStyle[] { PointStyle.Circle, PointStyle.Diamond, PointStyle.Triangle, PointStyle.Square }; XYMultipleSeriesRenderer renderer = BuildRenderer(colors, styles); int length = renderer.SeriesRendererCount; for (int i = 0; i < length; i++) { ((XYSeriesRenderer)renderer.GetSeriesRendererAt(i)).FillPoints = true; } SetChartSettings(renderer, "Average temperature", "Month", "Temperature", 0.5, 12.5, -10, 40, Color.LightGray, Color.LightGray); renderer.XLabels = 12; renderer.YLabels = 10; renderer.SetShowGrid(true); renderer.XLabelsAlign = Android.Graphics.Paint.Align.Right; renderer.SetYLabelsAlign(Android.Graphics.Paint.Align.Right); renderer.ZoomButtonsVisible = true; renderer.SetPanLimits(new double[] { -10, 20, -10, 40 }); renderer.SetZoomLimits(new double[] { -10, 20, -10, 40 }); XYMultipleSeriesDataset dataset = BuildDataset(titles, x, values); XYSeries series = dataset.GetSeriesAt(0); series.AddAnnotation("Vacation", 6, 30); Intent intent = ChartFactory.GetLineChartIntent(context, dataset, renderer, "Average temperature"); return(intent); }
/// <summary> /// Executes the chart demo. /// </summary> /// <param name="context"> the context </param> /// <returns> the built intent </returns> public override Intent execute(Context context) { string[] titles = new string[] { "Crete Air Temperature", "Skiathos Air Temperature" }; IList <double[]> x = new List <double[]>(); for (int i = 0; i < titles.Length; i++) { x.Add(new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }); } IList <double[]> values = new List <double[]>(); values.Add(new double[] { 12.3, 12.5, 13.8, 16.8, 20.4, 24.4, 26.4, 26.1, 23.6, 20.3, 17.2, 13.9 }); values.Add(new double[] { 9, 10, 11, 15, 19, 23, 26, 25, 22, 18, 13, 10 }); int[] colors = new int[] { Color.GREEN, Color.rgb(200, 150, 0) }; PointStyle[] styles = new PointStyle[] { PointStyle.CIRCLE, PointStyle.DIAMOND }; XYMultipleSeriesRenderer renderer = buildRenderer(colors, styles); renderer.PointSize = 5.5f; int length = renderer.SeriesRendererCount; for (int i = 0; i < length; i++) { XYSeriesRenderer r = (XYSeriesRenderer)renderer.getSeriesRendererAt(i); r.LineWidth = 5; r.FillPoints = true; } setChartSettings(renderer, "Weather data", "Month", "Temperature", 0.5, 12.5, 0, 40, Color.LTGRAY, Color.LTGRAY); renderer.XLabels = 12; renderer.YLabels = 10; renderer.ShowGrid = true; renderer.XLabelsAlign = Align.RIGHT; renderer.YLabelsAlign = Align.RIGHT; renderer.ZoomButtonsVisible = true; renderer.PanLimits = new double[] { -10, 20, -10, 40 }; renderer.ZoomLimits = new double[] { -10, 20, -10, 40 }; XYValueSeries sunSeries = new XYValueSeries("Sunshine hours"); sunSeries.add(1f, 35, 4.3); sunSeries.add(2f, 35, 4.9); sunSeries.add(3f, 35, 5.9); sunSeries.add(4f, 35, 8.8); sunSeries.add(5f, 35, 10.8); sunSeries.add(6f, 35, 11.9); sunSeries.add(7f, 35, 13.6); sunSeries.add(8f, 35, 12.8); sunSeries.add(9f, 35, 11.4); sunSeries.add(10f, 35, 9.5); sunSeries.add(11f, 35, 7.5); sunSeries.add(12f, 35, 5.5); XYSeriesRenderer lightRenderer = new XYSeriesRenderer(); lightRenderer.Color = Color.YELLOW; XYSeries waterSeries = new XYSeries("Water Temperature"); waterSeries.add(1, 16); waterSeries.add(2, 15); waterSeries.add(3, 16); waterSeries.add(4, 17); waterSeries.add(5, 20); waterSeries.add(6, 23); waterSeries.add(7, 25); waterSeries.add(8, 25.5); waterSeries.add(9, 26.5); waterSeries.add(10, 24); waterSeries.add(11, 22); waterSeries.add(12, 18); renderer.BarSpacing = 0.5; XYSeriesRenderer waterRenderer = new XYSeriesRenderer(); waterRenderer.Color = Color.argb(250, 0, 210, 250); XYMultipleSeriesDataset dataset = buildDataset(titles, x, values); dataset.addSeries(0, sunSeries); dataset.addSeries(0, waterSeries); renderer.addSeriesRenderer(0, lightRenderer); renderer.addSeriesRenderer(0, waterRenderer); waterRenderer.DisplayChartValues = true; waterRenderer.ChartValuesTextSize = 10; string[] types = new string[] { BarChart.TYPE, BubbleChart.TYPE, LineChart.TYPE, CubicLineChart.TYPE }; Intent intent = ChartFactory.getCombinedXYChartIntent(context, dataset, renderer, types, "Weather parameters"); return(intent); }
private void openChart() { int[] x = { 0, 1, 2, 3, 4, 5, 6, 7 }; int[] income = { 2000, 2500, 2700, 3000, 2800, 3500, 3700, 3800 }; int[] expense = { 2200, 2700, 2900, 2800, 2600, 3000, 3300, 3400 }; // Creating an XYSeries for Income XYSeries incomeSeries = new XYSeries("Income"); // Creating an XYSeries for Expense XYSeries expenseSeries = new XYSeries("Expense"); // Adding data to Income and Expense Series for (int i = 0; i < x.Length; i++) { incomeSeries.Add(i, income[i]); expenseSeries.Add(i, expense[i]); } // Creating a dataset to hold each series XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset(); // Adding Income Series to the dataset dataset.AddSeries(incomeSeries); // Adding Expense Series to dataset dataset.AddSeries(expenseSeries); // Creating XYSeriesRenderer to customize incomeSeries XYSeriesRenderer incomeRenderer = new XYSeriesRenderer(); incomeRenderer.Color = Color.Rgb(130, 130, 230); incomeRenderer.FillPoints = true; incomeRenderer.LineWidth = 2; incomeRenderer.DisplayChartValues = true; // Creating XYSeriesRenderer to customize expenseSeries XYSeriesRenderer expenseRenderer = new XYSeriesRenderer(); expenseRenderer.Color = Color.Rgb(220, 80, 80); expenseRenderer.FillPoints = true; expenseRenderer.LineWidth = 2; expenseRenderer.DisplayChartValues = true; // Creating a XYMultipleSeriesRenderer to customize the whole chart XYMultipleSeriesRenderer multiRenderer = new XYMultipleSeriesRenderer(); multiRenderer.XLabels = 0; multiRenderer.ChartTitle = "Income vs Expense Chart"; multiRenderer.XTitle = "Year 2012"; multiRenderer.YTitle = "Amount in Dollars"; multiRenderer.ZoomButtonsVisible = true; multiRenderer.BackgroundColor = Color.Transparent; for (int i = 0; i < x.Length; i++) { multiRenderer.AddXTextLabel(i, mMonth[i]); } // Adding incomeRenderer and expenseRenderer to multipleRenderer // Note: The order of adding dataseries to dataset and renderers to multipleRenderer // should be same multiRenderer.AddSeriesRenderer(incomeRenderer); multiRenderer.AddSeriesRenderer(expenseRenderer); // Creating an intent to plot bar chart using dataset and multipleRenderer Intent intent = ChartFactory.GetBarChartIntent(this, dataset, multiRenderer, BarChart.Type.Default); // Start Activity StartActivity(intent); }
/// <summary> /// Builds a bar multiple series dataset using the provided values. /// </summary> /// <param name="titles"> the series titles </param> /// <param name="values"> the values </param> /// <returns> the XY multiple bar dataset </returns> protected internal virtual XYMultipleSeriesDataset buildBarDataset(string[] titles, IList<double[]> values) { XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset(); int length = titles.Length; for (int i = 0; i < length; i++) { CategorySeries series = new CategorySeries(titles[i]); double[] v = values[i]; int seriesLength = v.Length; for (int k = 0; k < seriesLength; k++) { series.add(v[k]); } dataset.addSeries(series.toXYSeries()); } return dataset; }
public FJAReportChart(XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, Type type, FJABarChartPropertyModel property, Context ctx) : base(dataset, renderer, type) { Property = property; Context = ctx; }
/// <summary> /// Builds an XY multiple time dataset using the provided values. /// </summary> /// <param name="titles"> the series titles </param> /// <param name="xValues"> the values for the X axis </param> /// <param name="yValues"> the values for the Y axis </param> /// <returns> the XY multiple time dataset </returns> protected internal virtual XYMultipleSeriesDataset buildDateDataset(string[] titles, IList<DateTime[]> xValues, IList<double[]> yValues) { XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset(); int length = titles.Length; for (int i = 0; i < length; i++) { TimeSeries series = new TimeSeries(titles[i]); DateTime[] xV = xValues[i]; double[] yV = yValues[i]; int seriesLength = xV.Length; for (int k = 0; k < seriesLength; k++) { series.add(xV[k], yV[k]); } dataset.addSeries(series); } return dataset; }
public override Android.Content.Intent Execute(Android.Content.Context context) { String[] titles = new String[] { "Crete Air Temperature", "Skiathos Air Temperature" }; IList <double[]> x = new List <double[]>(); for (int i = 0; i < titles.Length; i++) { x.Add(new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }); } IList <double[]> values = new List <double[]>(); values.Add(new double[] { 12.3, 12.5, 13.8, 16.8, 20.4, 24.4, 26.4, 26.1, 23.6, 20.3, 17.2, 13.9 }); values.Add(new double[] { 9, 10, 11, 15, 19, 23, 26, 25, 22, 18, 13, 10 }); int[] colors = new int[] { Color.Green, Color.Rgb(200, 150, 0) }; PointStyle[] styles = new PointStyle[] { PointStyle.Circle, PointStyle.Diamond }; XYMultipleSeriesRenderer renderer = BuildRenderer(colors, styles); renderer.PointSize = 5.5f; int length = renderer.SeriesRendererCount; for (int i = 0; i < length; i++) { XYSeriesRenderer r = (XYSeriesRenderer)renderer.GetSeriesRendererAt(i); r.LineWidth = 5; r.FillPoints = true; } SetChartSettings(renderer, "Weather data", "Month", "Temperature", 0.5, 12.5, 0, 40, Color.LightGray, Color.LightGray); renderer.XLabels = 12; renderer.YLabels = 10; renderer.SetShowGrid(true); renderer.XLabelsAlign = Android.Graphics.Paint.Align.Right; renderer.SetYLabelsAlign(Android.Graphics.Paint.Align.Right); renderer.ZoomButtonsVisible = true; renderer.SetPanLimits(new double[] { -10, 20, -10, 40 }); renderer.SetZoomLimits(new double[] { -10, 20, -10, 40 }); XYValueSeries sunSeries = new XYValueSeries("Sunshine hours"); sunSeries.Add(1f, 35, 4.3); sunSeries.Add(2f, 35, 4.9); sunSeries.Add(3f, 35, 5.9); sunSeries.Add(4f, 35, 8.8); sunSeries.Add(5f, 35, 10.8); sunSeries.Add(6f, 35, 11.9); sunSeries.Add(7f, 35, 13.6); sunSeries.Add(8f, 35, 12.8); sunSeries.Add(9f, 35, 11.4); sunSeries.Add(10f, 35, 9.5); sunSeries.Add(11f, 35, 7.5); sunSeries.Add(12f, 35, 5.5); XYSeriesRenderer lightRenderer = new XYSeriesRenderer(); lightRenderer.Color = Color.Yellow; XYSeries waterSeries = new XYSeries("Water Temperature"); waterSeries.Add(1, 16); waterSeries.Add(2, 15); waterSeries.Add(3, 16); waterSeries.Add(4, 17); waterSeries.Add(5, 20); waterSeries.Add(6, 23); waterSeries.Add(7, 25); waterSeries.Add(8, 25.5); waterSeries.Add(9, 26.5); waterSeries.Add(10, 24); waterSeries.Add(11, 22); waterSeries.Add(12, 18); renderer.BarSpacing = 0.5; XYSeriesRenderer waterRenderer = new XYSeriesRenderer(); waterRenderer.Color = Color.Argb(250, 0, 210, 250); XYMultipleSeriesDataset dataset = BuildDataset(titles, x, values); dataset.AddSeries(0, sunSeries); dataset.AddSeries(0, waterSeries); renderer.AddSeriesRenderer(0, lightRenderer); renderer.AddSeriesRenderer(0, waterRenderer); waterRenderer.DisplayChartValues = true; waterRenderer.ChartValuesTextSize = 10; String[] types = new String[] { "Bar", BubbleChart.Type, LineChart.Type, CubicLineChart.Type }; Intent intent = ChartFactory.GetCombinedXYChartIntent(context, dataset, renderer, types, "Weather parameters"); return(intent); }
/// <summary> /// Builds an XY multiple dataset using the provided values. /// </summary> /// <param name="titles"> the series titles </param> /// <param name="xValues"> the values for the X axis </param> /// <param name="yValues"> the values for the Y axis </param> /// <returns> the XY multiple dataset </returns> protected internal virtual XYMultipleSeriesDataset buildDataset(string[] titles, IList<double[]> xValues, IList<double[]> yValues) { XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset(); addXYSeries(dataset, titles, xValues, yValues, 0); return dataset; }