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); } }
/// <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); }
/// <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); }
/// <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); }
/// <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; }
/// <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; }