public static XYDataset extractColumnFromHeatMapDataset(HeatMapDataset dataset, int column, IComparable seriesName)
 {
   XYSeries series = new XYSeries(seriesName);
   int ysampleCount = dataset.getYSampleCount();
   for (int index = 0; index < ysampleCount; ++index)
     series.add(dataset.getYValue(index), dataset.getZValue(column, index));
   return (XYDataset) new XYSeriesCollection(series);
 }
 public static XYDataset extractRowFromHeatMapDataset(HeatMapDataset dataset, int row, IComparable seriesName)
 {
   XYSeries series = new XYSeries(seriesName);
   int xsampleCount = dataset.getXSampleCount();
   for (int index = 0; index < xsampleCount; ++index)
     series.add(dataset.getXValue(index), dataset.getZValue(index, row));
   return (XYDataset) new XYSeriesCollection(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);
		}
	  }
示例#4
0
        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);
            }
        }
示例#5
0
        /// <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);
        }
示例#6
0
        /// <summary>
        /// Create a dataset to display in the chart.  Extract the values from the
        /// StateMod_Reservoir curve data.
        /// </summary>
        private DefaultTableXYDataset createDataset()
        {
            string routine = "StateMod_Reservoir_AreaCap_Graph_JFrame.createDataSet";
            DefaultTableXYDataset dataset = new DefaultTableXYDataset();

            IList <StateMod_ReservoirAreaCap> v = __res.getAreaCaps();
            int size = 0;

            if (v != null)
            {
                size = v.Count;
            }
            XYSeries series = new XYSeries("Reservoir " + __res.getID() + " (" + __res.getName() + ") Content/" + __type + " Curve", false, false);
            StateMod_ReservoirAreaCap ac = null;
            // Speed up checks in loop...
            bool do_area = true;

            if (__type.Equals("Seepage", StringComparison.OrdinalIgnoreCase))
            {
                do_area = false;
            }
            double value_prev = -10000000.0, value = 0.0, value2 = 0.0;
            double content     = 0.0;
            int    match_count = 0;

            for (int i = 0; i < size; i++)
            {
                ac = (StateMod_ReservoirAreaCap)v[i];
                // Curves will often have a very large content to protect
                // against out of bounds for interpolation.  However, if this
                // point is graphed, it causes the other values to appear
                // miniscule.  Therefore, omit the last point if it is much
                // larger than the previous value.
                if ((size > 4) && (i == (size - 1)) && ac.getConten() > 9000000.0)
                {
                    Message.printStatus(2, routine, "Skipping last point.  Seems to be very large bounding" + " value and might skew the graph.");
                    continue;
                }
                // Add X first, then Y...
                if (do_area)
                {
                    value = ac.getSurarea();
                }
                else
                {
                    value = ac.getSeepage();
                }
                if (value == value_prev)
                {
                    // This is needed because JFreeChart will not allow
                    // adjacent X values to be the same.
                    ++match_count;
                    value2 = value + match_count * .00001;
                }
                else
                {
                    value2 = value;
                }
                content = ac.getConten();
                // REVISIT SAM 2006-08-20
                // Not sure if content needs to be checked the same way for
                // duplicates.
                Message.printStatus(2, routine, "X=" + value2 + " y=" + content);
                series.add(value2, content);
                value_prev = value;
            }
            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;
	  }
示例#8
0
 public static XYSeries createMovingAverage(XYDataset source, int series, string name, double period, double skip)
 {
   if (source == null)
   {
     string str = "Null source (XYDataset).";
     Throwable.__\u003CsuppressFillInStackTrace\u003E();
     throw new IllegalArgumentException(str);
   }
   else if (period < 4.94065645841247E-324)
   {
     string str = "period must be positive.";
     Throwable.__\u003CsuppressFillInStackTrace\u003E();
     throw new IllegalArgumentException(str);
   }
   else if (skip < 0.0)
   {
     string str = "skip must be >= 0.0.";
     Throwable.__\u003CsuppressFillInStackTrace\u003E();
     throw new IllegalArgumentException(str);
   }
   else
   {
     XYSeries xySeries = new XYSeries((IComparable) name);
     if (source.getItemCount(series) > 0)
     {
       double num1 = source.getXValue(series, 0) + skip;
       int i2 = source.getItemCount(series) - 1;
       while (i2 >= 0)
       {
         double xvalue1 = source.getXValue(series, i2);
         if (xvalue1 >= num1)
         {
           int num2 = 0;
           double num3 = 0.0;
           double num4 = xvalue1 - period;
           int num5 = 0;
           int num6 = 0;
           while (num6 == 0)
           {
             if (i2 - num5 >= 0)
             {
               double xvalue2 = source.getXValue(series, i2 - num5);
               Number y = source.getY(series, i2 - num5);
               if (xvalue2 > num4)
               {
                 if (y != null)
                 {
                   num3 += y.doubleValue();
                   ++num2;
                 }
               }
               else
                 num6 = 1;
             }
             else
               num6 = 1;
             ++num5;
           }
           if (num2 > 0)
             xySeries.add(xvalue1, num3 / (double) num2);
           else
             xySeries.add(xvalue1, (Number) null);
         }
         i2 += -1;
       }
     }
     return xySeries;
   }
 }