Menu

Java_Average_GWTHighcharts

Velo
2014-05-14
2014-05-20
  • Velo

    Velo - 2014-05-14
     

    Last edit: Velo 2014-05-21
  • Shawn Quinn

    Shawn Quinn - 2014-05-19

    Greetings! There's nothing within the GWT Highcharts wrapper or Highcharts.js (that I know of) to run statistical methods on a series, but given that GWT is all Java you can certainly just write a simple method to calculate the average for you (similar to what is shown in that jsfiddle example). E.g.

        public static double getSeriesAverage(Series series) {
            Point[] points = series.getPoints();
            double sum = 0;
            for (Point point : points) {
                sum += point.getY().doubleValue();
            }
            return sum / points.length;
        }
    

    Hope that helps.

     
  • Velo

    Velo - 2014-05-19
     

    Last edit: Velo 2014-05-21
  • Velo

    Velo - 2014-05-19
     

    Last edit: Velo 2014-05-21
  • Shawn Quinn

    Shawn Quinn - 2014-05-20

    You'll need to put the Series that you're interested in running the average on in a variable first (e.g. Series series = chart.createSeries()...) and then call the "getSeriesAverage()" method after you have added the points to the series.

     

    Last edit: Shawn Quinn 2014-05-20
  • Velo

    Velo - 2014-05-20
     

    Last edit: Velo 2014-05-20
  • Velo

    Velo - 2014-05-20

    i did this:

            Series series=chart.createSeries()  
            .setName("London") 
            .setPoints(new Number[]  {
                3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8 
            })
        ; chart.addSeries(series);
        getSeriesAverage(series);
    

    and now i do't know yet, how to draw this line for average with value,

     

    Last edit: Velo 2014-05-20

Log in to post a comment.