Package com.googlecode.charts4j

Examples of com.googlecode.charts4j.LineChart


      line1 = Plots.newLine(DataUtil.scaleWithinRange(min, max, points), lineColor, lineLabel);
    line1.setLineStyle(LineStyle.newLineStyle(1, 1, 0));
    line1.addShapeMarkers(Shape.CIRCLE, lineColor, pointSize);
   
    // Defining chart.
    LineChart chart = GCharts.newLineChart(line1);
    chart.setSize(w, h);
    if (title != null)
      chart.setTitle(title, Color.BLACK, 20);
    // chart.addHorizontalRangeMarker(40, 60, Color.newColor(Color.RED, 30));
    // chart.addVerticalRangeMarker(70, 90, Color.newColor(Color.GREEN, 30));
    chart.setGrid(points.size(), 100/(max/10), 2, 1);
   
    // selected indexes - vertical lines
    if (selectedIndexes != null)
      for (int i=0; i<selectedIndexes.size(); i++)
      {
        if (selectedIndexes.get(i) >= 0)
        {
          double position = (double)selectedIndexes.get(i)/points.size()*100;

          // to account for rounding errors
          if (position < 1)
            position = 1;

          if (position > 99)
            position = 99;
         
          //p(position);
         
          chart.addVerticalRangeMarker(position, position + 1, Color.RED )// positions must be in [0,100]
        }
      }
   
    // // Defining axis info and styles
    AxisStyle axisStyle = AxisStyle.newAxisStyle(Color.BLACK, axisFontSize, AxisTextAlignment.CENTER);
    AxisLabels yAxis = AxisLabelsFactory.newNumericRangeAxisLabels(0, max);
    yAxis.setAxisStyle(axisStyle);

    // // Adding axis info to chart.
    chart.addYAxisLabels(yAxis);

    // url
    String url = chart.toURLString();
   
    // browse
    if (showInBrowser)
      net.wigis.svetlin.__Browser.openUrl(url);

View Full Code Here


     *            args not read.
     * @throws IOException
     */
    public static void main(String...s) throws IOException {
        Plot plot = Plots.newPlot(Data.newData(0, 66.6, 33.3, 100));
        LineChart chart = GCharts.newLineChart(plot);
        displayUrlString(chart.toURLString());
    }
View Full Code Here

    @Test
    //Defining a very simple chart.
    public void example1() {
        // EXAMPLE CODE START
        Plot plot = Plots.newPlot(Data.newData(0, 66.6, 33.3, 100));
        LineChart chart = GCharts.newLineChart(plot);
        String url = chart.toURLString();
        // EXAMPLE CODE END. Use this url string in your web or
        // Internet application.
        Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).info(url);
        String expectedString = "http://chart.apis.google.com/chart?chd=e:AAqnVU..&chs=200x125&cht=lc";
        assertEquals("Junit error", normalize(expectedString), normalize(url));
View Full Code Here

    @Test
    //Note that data, grids, axis labels, range markers all snap together nicely.
    public void example2() {
        // EXAMPLE CODE START
        Plot plot = Plots.newPlot(Data.newData(0, 66.6, 33.3, 100));
        LineChart chart = GCharts.newLineChart(plot);
        chart.addHorizontalRangeMarker(33.3, 66.6, LIGHTBLUE);
        chart.setGrid(33.3, 33.3, 3, 3);
        chart.addXAxisLabels(AxisLabelsFactory.newAxisLabels(Arrays.asList("Peak","Valley"), Arrays.asList(33.3,66.6)));
        chart.addYAxisLabels(AxisLabelsFactory.newNumericAxisLabels(0,33.3,66.6,100));
        String url = chart.toURLString();
        // EXAMPLE CODE END. Use this url string in your web or
        // Internet application.
        Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).info(url);
        String expectedString = "http://chart.apis.google.com/chart?chs=200x125&chd=e:AAqnVU..&chg=33.3,33.3,3,3&chxt=y,x&chxp=0,0.0,33.3,66.6,100.0|1,33.3,66.6&chxr=0,0.0,100.0|1,0.0,100.0&chxl=1:|Peak|Valley&chm=r,ADD8E6,0,0.33,0.67&cht=lc";
        assertEquals("Junit error", normalize(expectedString), normalize(url));
View Full Code Here

        // EXAMPLE CODE START
        Plot plot = Plots.newPlot(Data.newData(0, 10, 20, 30, 40, 50, 60, 70, 80, 90));
        plot.addShapeMarkers(Shape.DIAMOND, BLUE, 12);

        //Same data expressed in different charts.
        LineChart lineChart = GCharts.newLineChart(plot);
        lineChart.setSize(400, 200);
        BarChart barChart = GCharts.newBarChart(plot);
        barChart.setSize(400, 200);
        RadarChart radarChart = GCharts.newRadarChart(plot);
        radarChart.setSize(400, 200);
        ScatterPlot  scatterChart = GCharts.newScatterPlot(plot);
        scatterChart.setSize(400, 200);
        XYLineChart  xyLineChart = GCharts.newXYLineChart(plot);
        xyLineChart.setSize(400, 200);


        String lineChartUrl = lineChart.toURLString();
        String barChartUrl = barChart.toURLString();
        String radarChartUrl = radarChart.toURLString();
        String scatterChartUrl = scatterChart.toURLString();
        String xyLineChartUrl = xyLineChart.toURLString();
View Full Code Here

        line2.addShapeMarkers(Shape.DIAMOND, SKYBLUE, 12);
        line2.addShapeMarkers(Shape.DIAMOND, Color.WHITE, 8);


        // Defining chart.
        LineChart chart = GCharts.newLineChart(line1, line2);
        chart.setSize(600, 450);
        chart.setTitle("Web Traffic|(in billions of hits)", WHITE, 14);
        chart.addHorizontalRangeMarker(40, 60, Color.newColor(RED, 30));
        chart.addVerticalRangeMarker(70, 90, Color.newColor(GREEN, 30));
        chart.setGrid(25, 25, 3, 2);

        // Defining axis info and styles
        AxisStyle axisStyle = AxisStyle.newAxisStyle(WHITE, 12, AxisTextAlignment.CENTER);
        AxisLabels xAxis = AxisLabelsFactory.newAxisLabels("Nov", "Dec", "Jan", "Feb", "Mar");
        xAxis.setAxisStyle(axisStyle);
        AxisLabels xAxis2 = AxisLabelsFactory.newAxisLabels("2007", "2007", "2008", "2008", "2008");
        xAxis2.setAxisStyle(axisStyle);
        AxisLabels yAxis = AxisLabelsFactory.newAxisLabels("", "25", "50", "75", "100");
        AxisLabels xAxis3 = AxisLabelsFactory.newAxisLabels("Month", 50.0);
        xAxis3.setAxisStyle(AxisStyle.newAxisStyle(WHITE, 14, AxisTextAlignment.CENTER));
        yAxis.setAxisStyle(axisStyle);
        AxisLabels yAxis2 = AxisLabelsFactory.newAxisLabels("Hits", 50.0);
        yAxis2.setAxisStyle(AxisStyle.newAxisStyle(WHITE, 14, AxisTextAlignment.CENTER));
        yAxis2.setAxisStyle(axisStyle);

        // Adding axis info to chart.
        chart.addXAxisLabels(xAxis);
        chart.addXAxisLabels(xAxis2);
        chart.addXAxisLabels(xAxis3);
        chart.addYAxisLabels(yAxis);
        chart.addYAxisLabels(yAxis2);

        // Defining background and chart fills.
        chart.setBackgroundFill(Fills.newSolidFill(Color.newColor("1F1D1D")));
        LinearGradientFill fill = Fills.newLinearGradientFill(0, Color.newColor("363433"), 100);
        fill.addColorAndOffset(Color.newColor("2E2B2A"), 0);
        chart.setAreaFill(fill);
        String url = chart.toURLString();
        // EXAMPLE CODE END. Use this url string in your web or
        // Internet application.
        Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).info(url);
        String expectedString = "http://chart.apis.google.com/chart?chco=CA3D05,87CEEB&chd=e:AAB4DhEzFxGnHrJRLhOZRmUpXCYZYpYAXCWfXCZIczhmmtrKuE,..-H8e7M6O5Y4U2u0exmuZrWo9nmnWn.o9pgo9m3jMeZZSU1R7&chdl=My+Website.com|Competition.com&chf=bg,s,1F1D1D|c,lg,0,363433,1.0,2E2B2A,0.0&chg=25.0,25.0,3,2&chls=3,1,0|3,1,0&chm=r,FF00004C,0,0.40,0.60|R,0080004C,0,0.70,0.90|d,CA3D05,0,-1,12,0|d,FFFFFF,0,-1,8,0|d,87CEEB,1,-1,12,0|d,FFFFFF,1,-1,8,0&chs=600x450&cht=lc&chts=FFFFFF,14&chtt=Web+Traffic%7C%28in+billions+of+hits%29&chxl=0:||25|50|75|100|1:|Hits|2:|Nov|Dec|Jan|Feb|Mar|3:|2007|2007|2008|2008|2008|4:|Month&chxp=1,50.0|4,50.0&chxr=1,0.0,100.0|4,0.0,100.0&chxs=0,FFFFFF,12,0|1,FFFFFF,12,0|2,FFFFFF,12,0|3,FFFFFF,12,0|4,FFFFFF,14,0&chxt=y,y,x,x,x";
        assertEquals("Junit error", normalize(expectedString), normalize(url));
View Full Code Here

        line2.addShapeMarkers(Shape.CIRCLE, BLACK, 7);
        line2.setFillAreaColor(LIGHTGREEN);


        // Defining chart.
        LineChart chart = GCharts.newLineChart(line1,line2);
        chart.setSize(600, 450);
        chart.setTitle("S & P 500|1962 - 2008", WHITE, 14);

        // Defining axis info and styles
        AxisStyle axisStyle = AxisStyle.newAxisStyle(WHITE, 12, AxisTextAlignment.CENTER);
        AxisLabels yAxis = AxisLabelsFactory.newNumericRangeAxisLabels(0, sp500[sp500.length-1]);
        yAxis.setAxisStyle(axisStyle);
        AxisLabels xAxis1 = AxisLabelsFactory.newAxisLabels(Arrays.asList("Fed Chiefs:","Burns","Volcker","Greenspan","Bernanke"), Arrays.asList(5,18,39,55,92));
        xAxis1.setAxisStyle(axisStyle);
        AxisLabels xAxis2 = AxisLabelsFactory.newNumericRangeAxisLabels(1962, 2008);
        xAxis2.setAxisStyle(axisStyle);
        AxisLabels xAxis3 = AxisLabelsFactory.newAxisLabels("Year", 50.0);
        xAxis3.setAxisStyle(AxisStyle.newAxisStyle(WHITE, 14, AxisTextAlignment.CENTER));

        // Adding axis info to chart.
        chart.addYAxisLabels(yAxis);
        chart.addXAxisLabels(xAxis1);
        chart.addXAxisLabels(xAxis2);
        chart.addXAxisLabels(xAxis3);
        chart.setGrid(100, 6.78, 5, 0);

        // Defining background and chart fills.
        chart.setBackgroundFill(Fills.newSolidFill(BLACK));
        chart.setAreaFill(Fills.newSolidFill(Color.newColor("708090")));
        String url = chart.toURLString();
        // EXAMPLE CODE END. Use this url string in your web or
        // Internet application.
        Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).info(url);
        Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).info(url.length() + "");
        String expectedString = "http://chart.apis.google.com/chart?chf=bg,s,000000|c,s,708090&chs=600x450&chd=e:CsDMDmD8EGEbD6D8EIE.EKC3D1EkEDEHEmFxFOF.HCHGI.KYKlL0O9OBRtSuT.TqaNgKpa0j-e46xilhvVzx1r8x-7,CsCyC4C.DFDMDTDbDiDqDyD7EEENEWEgEqE0E.FKFWFiFuF7GIGWGkGzHCHSHiHzIFIXIqI9JRJmJ7KSKpLALZLzMN&chtt=S+%26+P+500%7C1962+-+2008&chts=FFFFFF,14&chg=100.0,6.78,5,0&chxt=y,x,x,x&chxr=0,0.0,1475.25|1,0.0,100.0|2,1962.0,2008.0|3,0.0,100.0&chxs=0,FFFFFF,12,0|1,FFFFFF,12,0|2,FFFFFF,12,0|3,FFFFFF,14,0&chxl=1:|Fed+Chiefs%3A|Burns|Volcker|Greenspan|Bernanke|3:|Year&chxp=1,5,18,39,55,92|3,50.0&chdl=S+%26+P+500|Inflation&chco=FFFF00,32CD32&chm=o,FFFF00,0,-1,10,0|o,000000,0,-1,7,0|v,0000FF,0,8,3,0|v,0000FF,0,17,3,0|v,0000FF,0,24,3,0|v,0000FF,0,40,3,0|B,FFFFE0,0,0,0|o,00FF00,1,-1,10,0|o,000000,1,-1,7,0|B,90EE90,1,0,0&chls=3,1,0|3,1,0&cht=lc";
View Full Code Here

            final Line[] lines = new Line[2];
            lines[0] = valuesLine;
            lines[1] = avgLine;
        
            // new chart
            final LineChart chart = GCharts.newLineChart(lines);

            // set the size
            chart.setSize(x, y);
            chart.addYAxisLabels(AxisLabelsFactory.newNumericRangeAxisLabels(state.getMinInt(), state.getMaxInt()));

        //    final String titleText = title.toUpperCase() + " = "
        //    + (state.getNewest()).getValueString() + " " + units + "   " + " (" + state.size() + ") "
        //    + Utils.getDate();
     
   
            //String t = constants.get("t");
            //if(t!=null) chart.setTitle();

            // add grid
            chart.setGrid(5, 20, 3, 2);

            // place three time stamps on y label... oldest, middle, and newest
      //      chart.addXAxisLabels(AxisLabelsFactory.newAxisLabels(Arrays.asList(state.getOldest().getAge(), ((TimedEntry) state.get((getState().size() / 2)))
        //            .getAge(), state.getNewest().getAge()), Arrays.asList(7, 50, 93)));

            // construct a URL that can be used to display this graph 
            return chart.toURLString();

        } catch (final Exception e) {
            return null;
        }
    }
View Full Code Here

           
            valuesLine.addShapeMarker(Shape.VERTICAL_LINE_FULL, Color.BLACK, 1, (state.size()/2));
            valuesLine.addShapeMarker(Shape.VERTICAL_LINE_FULL, Color.BLACK, 1, (state.size()/4));
            valuesLine.addShapeMarker(Shape.VERTICAL_LINE_FULL, Color.BLACK, 1, ((state.size()/2) + (state.size()/4)));
           
            LineChart chart = GCharts.newLineChart(new Line[] {valuesLine}); // , redLine, orangeLine});

            // set the size
            chart.setSize(x, y);
            chart.addYAxisLabels(AxisLabelsFactory.newNumericRangeAxisLabels(state.getMinInt(), state.getMaxInt()));

            chart.setTitle(title);

            // add grid
            chart.setGrid(5, 20, 3, 2);

            // place three time stamps on y label... oldest, middle, and newest
     
            // chart.addXAxisLabels(AxisLabelsFactory.newAxisLabels(Arrays.asList( "12", "56", "90" )));
               
                //state.getOldest().getAge(), ((TimedEntry) state.get((getState().size() / 2)))
        //            .getAge(), state.getNewest().getAge()), Arrays.asList(7, 50, 93)));

           
       
           
            // construct a URL that can be used to display this graph 
            return chart.toURLString();

        } catch (final Exception e) {
            return null;
        }
  }
View Full Code Here

           
            valuesLine.addShapeMarker(Shape.VERTICAL_LINE_FULL, Color.BLACK, 2, (state.size()/2));
            valuesLine.addShapeMarker(Shape.VERTICAL_LINE_FULL, Color.BLACK, 2, (state.size()/4));
            valuesLine.addShapeMarker(Shape.VERTICAL_LINE_FULL, Color.BLACK, 2, ((state.size()/2) + (state.size()/4)));
          
            LineChart chart = GCharts.newLineChart(new Line[] {valuesLine});

            // set the size
            chart.setSize(x, y);
           
            // add grid
            chart.setGrid(5, 20, 3, 2);
 
            // construct a URL that can be used to display this graph 
            return chart.toURLString();

        } catch (final Exception e) {
            return null;
        }
  }
View Full Code Here

TOP

Related Classes of com.googlecode.charts4j.LineChart

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.