Package org.one2team.highcharts.shared

Examples of org.one2team.highcharts.shared.ChartOptions


    // ChartOptions creation
    // ----------------------
    //  The createHighchartsDemoColumnBasic method describes the creation of
    //   a java chartOption. It is a java equivalent to javascript Highcharts sample
    //   (see http://highcharts.com/demo/column-basic)
    ChartOptions chartOptions1 = highchartsSamples.createColumnBasic ();

    // ====================================================================
    // Chart export
    // ----------------
    // Inputs :
    //    1. chartOptions : the java ChartOptions to be exported,
    //    2. exportFile  : file to export to.
    HighchartsExporter<ChartOptions> pngExporter = ExportType.png.createExporter ();
    pngExporter.export (chartOptions1, null, new File (exportDirectory, "column-basic.png"));
   
//    // ====================================================================
//    // Another example using the same exporter
//    // ---------------------------------------
    ChartOptions chartOptions2 = highchartsSamples.createPieChart ();
    pngExporter.export (chartOptions2, null, new File (exportDirectory, "pie-chart.png"));
//   
//    // ====================================================================
//    // An example exporting to JPEG
//    // ---------------------------------------
    ChartOptions chartOptions3 = highchartsSamples.createTimeDataWithIrregularIntervals ();
    final HighchartsExporter<ChartOptions> jpegExporter = ExportType.jpeg.createExporter ();
    jpegExporter.export (chartOptions3, null, new File (exportDirectory, "time-data-with-irregular-intervals.jpeg"));
   
    // ====================================================================
    // Chart export with a json input (instead of a java one)
View Full Code Here


    // ChartOptions creation
    // ----------------------
    //  The createHighchartsDemoColumnBasic method describes the creation of
    //   a java chartOption. It is a java equivalent to javascript Highcharts sample
    //   (see http://highcharts.com/demo/column-basic)
    ChartOptions chartOptions1 = highchartsSamples.createColumnBasic ();

    // ====================================================================
    // Chart export
    // ----------------
    // Inputs :
View Full Code Here

    return SINGLETON;
  }

  public ChartOptions createTimeDataWithIrregularIntervals () {
    // http://highcharts.com/demo/spline-irregular-time
    ChartOptions chartOptions = factory.createChartOptions ();
    chartOptions.getChart ().setWidth (800).setHeight (600)
        .setDefaultSeriesType (SeriesType.spline).setMarginLeft (70)
        .setMarginTop (80);

    // titles
    chartOptions.getTitle ().setText (
        "Snow depth in the Vikjafjellet mountain, Norway");
    chartOptions.getSubtitle ().setText (
        "An example of irregular time data in Highcharts JS");

    // axis
    chartOptions.getXAxis ().setType ("datetime").getDateTimeLabelFormats ()
        .set (TimeUnit.month, "%e. %b").set (TimeUnit.year, "%b");
    chartOptions.getYAxis ().setMin (0).getTitle ().setText ("Snow depth (m)");

    // plotOptions
    chartOptions
        .getPlotOptions ()
        .getPie ()
        .setAllowPointSelect (true)
        .getDataLabels ()
        .setEnabled (true)
        .setColor ("#000000")
        .setFormatter (
            "function() {return '<b>'+ this.point.name +'</b>: '+ this.y +' %';}");

    Series newSeries = factory.createSeries ().setName ("Winter 2007-2008");
    chartOptions.getSeries ().pushElement (newSeries);
    newSeries
        .getData ()
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1970, 9, 27)).setY (0))
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1970, 10, 10)).setY (0.6))
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1970, 10, 18)).setY (0.7))
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1970, 11, 2)).setY (0.8))
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1970, 11, 9)).setY (0.6))
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1970, 11, 16)).setY (0.6))
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1970, 11, 28)).setY (0.67))
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1971, 0, 1)).setY (0.81))
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1971, 0, 8)).setY (0.78))
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1971, 0, 12)).setY (0.98))
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1971, 0, 27)).setY (1.84))
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1971, 1, 10)).setY (1.8))
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1971, 1, 18)).setY (1.8))
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1971, 1, 24)).setY (1.92))
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1971, 2, 4)).setY (2.49))
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1971, 2, 11)).setY (2.79))
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1971, 2, 15)).setY (2.73))
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1971, 2, 25)).setY (2.61))
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1971, 3, 2)).setY (2.76))
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1971, 3, 6)).setY (2.82))
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1971, 3, 13)).setY (2.8))
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1971, 4, 3)).setY (2.1))
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1971, 4, 26)).setY (1.1))
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1971, 5, 9)).setY (0.25))
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1971, 5, 12)).setY (0));

    newSeries = factory.createSeries ().setName ("Winter 2008-2009");
    chartOptions.getSeries ().pushElement (newSeries);
    newSeries
        .getData ()
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1970, 9, 18)).setY (0))
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1970, 9, 26)).setY (0.2))
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1970, 11, 1)).setY (0.47))
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1970, 11, 11)).setY (0.55))
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1970, 11, 25)).setY (1.38))
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1971, 0, 8)).setY (1.38))
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1971, 0, 15)).setY (1.38))
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1971, 1, 1)).setY (1.38))
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1971, 1, 8)).setY (1.48))
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1971, 1, 21)).setY (1.5))
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1971, 2, 12)).setY (1.89))
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1971, 2, 25)).setY (2.0))
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1971, 3, 4)).setY (1.94))
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1971, 3, 9)).setY (1.91))
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1971, 3, 13)).setY (1.75))
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1971, 3, 19)).setY (1.6))
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1971, 4, 25)).setY (0.6))
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1971, 4, 31)).setY (0.35))
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1971, 5, 7)).setY (0));

    newSeries = factory.createSeries ().setName ("Winter 2009-2010");
    chartOptions.getSeries ().pushElement (newSeries);
    newSeries
        .getData ()
        .pushElement (
            factory.createPoint ().setX (getDateUTC (1970, 9, 9)).setY (0))
        .pushElement (
View Full Code Here

    return chartOptions;
  }

  public ChartOptions createPieChart () {
    // http://highcharts.com/demo/pie-basic
    ChartOptions chartOptions = factory.createChartOptions ();
    chartOptions.getChart ().setWidth (800).setHeight (600).setMarginLeft (70)
        .setMarginTop (80);
    // title
    chartOptions.getTitle ().setText (
        "Browser market shares at a specific website, 2010");

    // plotOptions
    chartOptions
        .getPlotOptions ()
        .getPie ()
        .setAllowPointSelect (true)
        .getDataLabels ()
        .setEnabled (true)
        .setColor ("#000000")
        .setFormatter (
            "function() {return '<b>'+ this.point.name +'</b>: '+ this.y +' %';}");

    Series newSeries = factory.createSeries ().setName ("Browser share")
        .setType ("pie");
    chartOptions.getSeries ().pushElement (newSeries);
    newSeries
        .getData ()
        .pushElement (factory.createPoint ().setName ("Firefox").setY (45))
        .pushElement (factory.createPoint ().setName ("IE").setY (26.8))
        .pushElement (
View Full Code Here

    return chartOptions;
  }

  public ChartOptions createColumnBasic () {
    // http://highcharts.com/demo/column-basic
    ChartOptions chartOptions = factory.createChartOptions ();

    chartOptions.getChart ().setDefaultSeriesType (SeriesType.column)
        .setWidth (800).setHeight (400).setMarginLeft (70).setMarginTop (80);

    // titles
    chartOptions.getTitle ().setText ("Monthly Average Rainfall");
    chartOptions.getSubtitle ().setText ("Source: WorldClimate.com");

    // xAxis
    chartOptions.getXAxis ().getCategories ().pushString ("Jan").pushString ("Feb")
        .pushString ("Mar").pushString ("Apr").pushString ("May").pushString ("Jun")
        .pushString ("Jul").pushString ("Aug").pushString ("Sep").pushString ("Oct")
        .pushString ("Nov").pushString ("Dec");
    // yAxis
    chartOptions.getYAxis ().setMin (0).getTitle ().setText ("Rainfall (mm)");

    // Legend
    chartOptions.getLegend ().setLayout ("vertical").setAlign ("left")
        .setVerticalAlign ("top").setX (100).setY (70);

    // PlotOptions
    chartOptions.getPlotOptions ().getColumn ().setBorderWidth (0);

    // Several series
    addSeries (chartOptions, "Tokyo", new double[] { 49.9, 71.5, 106.4, 129.2,
        144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4 });
View Full Code Here

TOP

Related Classes of org.one2team.highcharts.shared.ChartOptions

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.