예제 #1
0
        /// <summary>
        /// Create the chart using the data.
        /// </summary>
        private JFreeChart createChart(DefaultTableXYDataset dataset)
        {
            string xlabel = "Surface Area (ACRE)";

            if (__type.Equals("Seepage"))
            {
                xlabel = "Seepage (AF/M)";
            }
            JFreeChart chart = ChartFactory.createXYLineChart("Reservoir Content/" + __type + " Curve", xlabel, "Content (ACFT)", dataset, PlotOrientation.VERTICAL, false, true, false);

            chart.addSubtitle(new TextTitle(__res.getID() + " (" + __res.getName() + ")"));
            //TextTitle source = new TextTitle("Source: rgtTW.res");
            //source.setFont(new Font("SansSerif", Font.PLAIN, 10));
            //source.setPosition(RectangleEdge.BOTTOM);
            //source.setHorizontalAlignment(HorizontalAlignment.RIGHT);
            //chart.addSubtitle(source);

            chart.setBackgroundPaint(Color.WHITE);

            XYPlot plot = (XYPlot)chart.getPlot();

            plot.setBackgroundPaint(Color.white);
            plot.setRangeGridlinePaint(Color.lightGray);

            NumberAxis rangeAxis = (NumberAxis)plot.getRangeAxis();

            rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

            return(chart);
        }
예제 #2
0
        public static void Main(string[] args)
        {
            /// <summary>
            /// Getting time series
            /// </summary>
            TimeSeries series = CsvTradesLoader.loadBitstampSeries().subseries(0, Period.hours(6));

            /// <summary>
            /// Creating the OHLC dataset
            /// </summary>
            OHLCDataset ohlcDataset = createOHLCDataset(series);

            /// <summary>
            /// Creating the additional dataset
            /// </summary>
            TimeSeriesCollection xyDataset = createAdditionalDataset(series);

            /// <summary>
            /// Creating the chart
            /// </summary>
            JFreeChart chart = ChartFactory.createCandlestickChart("Bitstamp BTC price", "Time", "USD", ohlcDataset, true);
            // Candlestick rendering
            CandlestickRenderer renderer = new CandlestickRenderer();

            renderer.AutoWidthMethod = CandlestickRenderer.WIDTHMETHOD_SMALLEST;
            XYPlot plot = chart.XYPlot;

            plot.Renderer = renderer;
            // Additional dataset
            int index = 1;

            plot.setDataset(index, xyDataset);
            plot.mapDatasetToRangeAxis(index, 0);
            XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(true, false);

            renderer2.setSeriesPaint(index, Color.blue);
            plot.setRenderer(index, renderer2);
            // Misc
            plot.RangeGridlinePaint = Color.lightGray;
            plot.BackgroundPaint    = Color.white;
            NumberAxis numberAxis = (NumberAxis)plot.RangeAxis;

            numberAxis.AutoRangeIncludesZero = false;
            plot.DatasetRenderingOrder       = DatasetRenderingOrder.FORWARD;

            /// <summary>
            /// Displaying the chart
            /// </summary>
            displayChart(chart);
        }
예제 #3
0
        public void RunColumnChart()
        {
            chartType = Utilities.ChartType.CHART_COLUMN;

            // Get the a reference to the ShinobiChart from the ChartFragment
            ColumnSeries series = new ColumnSeries();

            Com.ShinobiControls.Charts.ChartFragment chartFragment =
                (Com.ShinobiControls.Charts.ChartFragment) _mainActivity.FragmentManager.FindFragmentById(Resource.Id.chart1);

            IShinobiChart shinobiChart = chartFragment.ShinobiChart;

            if(shinobiChart.Series.Count>0)
                shinobiChart.RemoveSeries(shinobiChart.Series[0]);

            if (shinobiChart.Series.Count > 0)
                series = (ColumnSeries) shinobiChart.Series [0];

            // TODO: replace <license_key_here> with you trial license key
            shinobiChart.SetLicenseKey(licenseKey);

            shinobiChart.RedrawChart ();
            //shinobiChart.Title ="Closing Stock Price for Google Inc. (GOOG)";

            // Create the X axis with pre-defined default range
            DateRange xAxisDefaultRange = new DateRange(new DateTime(2012, 1, 1), new DateTime(2014, 12, 31));

            DateTimeAxis xAxis = new DateTimeAxis(xAxisDefaultRange);

            xAxis.Title = "Datum";
            xAxis.GesturePanningEnabled = true;
            xAxis.GestureZoomingEnabled = true;
            xAxis.Style.InterSeriesPadding = 0;
            xAxis.Style.InterSeriesSetPadding = 0;

            shinobiChart.XAxis = xAxis;

            List<BusinessLayer.PersonUmsatz> PersonUmsatzList =  _stateClass._person.GetPersonTimeUmsatz ("36", MainActivity.User);

            List<IData> dataPoints = LoadStockPriceData(PersonUmsatzList);
            int yHighestValue = this.GetHighestYValue (PersonUmsatzList);
            // Add ten percent to get a gap at the top of the columns
            yHighestValue = (int)(yHighestValue * 1.1);


            // Create the Y axis
            NumberAxis yAxis = new NumberAxis(new NumberRange(0.0,  yHighestValue ));

            yAxis.Title =_mainActivity.Resources.GetString(Resource.String.Umsatz) + " (Euro)";

            yAxis.GesturePanningEnabled = true;
            yAxis.GestureZoomingEnabled = true;
            shinobiChart.YAxis = yAxis;

            // Create the line series
            DataAdapter dataAdapter = new SimpleDataAdapter();



            // Load and add the stock price data
            dataAdapter.AddAll(dataPoints);
            series.DataAdapter = dataAdapter;

            // Add the series to the chart
            shinobiChart.AddSeries(series);

        }