Menu

Showcase for Gauge chart

b3t
2014-03-12
2014-03-12
  • b3t

    b3t - 2014-03-12

    GWT Highcharts 1.6.0 supports the Gauge chart.
    Is it possible have a showcase for this chart type?

    Thanks

     

    Last edit: b3t 2014-03-12
  • Shawn Quinn

    Shawn Quinn - 2014-03-12

    We do have a new showcase application coming with a bunch of new examples in it, including gauge's. Until that gets published, here's the gauge example source code in case it helps:

        public Chart createChart() {
    
            final Chart chart = new Chart()
                    .setType(Series.Type.GAUGE)
                    .setAlignTicks(false)
                    .setPlotBackgroundImage(null)
                    .setBorderWidth(0)
                    .setPlotShadow(false)
                    .setChartTitle(new ChartTitle()
                            .setText("Speedometer with dual axes")
                    )
                    .setPane(new Pane()
                            .setStartAngle(-150)
                            .setEndAngle(150)
                    );
    
            chart.setGaugePlotOptions(new GaugePlotOptions()
                    .setDataLabels(new DataLabels()
                            .setEnabled(true)
                            .setY(30)
                            .setFormat("{point.y} km/h")
                    )
                    .setPivotOptions(
                            new Pivot()
                                    .setRadius("2%")
                    )
                    .setDialOptions(
                            new Dial()
                                    .setRearLength("0%")
                                    .setBaseWidth(10)
                    )
            );
    
            // Primary axis
            chart.getYAxis(0)
                    .setMin(0)
                    .setMax(200)
                    .setTickPosition(Axis.TickPosition.INSIDE)
                    .setMinorTickPosition(Axis.TickPosition.INSIDE)
                    .setLineColor("#339")
                    .setTickColor("#339")
                    .setMinorTickColor("#339")
                    .setOffset(-25)
                    .setLineWidth(2)
                    .setTickLength(5)
                    .setMinorTickLength(5)
                    .setEndOnTick(false)
                    .setLabels(
                            new YAxisLabels()
                                    // There is no documented "distance" option for gauge chart axes
                                    .setOption("distance", -20)
                    )
            ;
    
            // Secondary axis
            chart.getYAxis(1)
                    .setMin(0)
                    .setMax(124)
                    .setTickPosition(Axis.TickPosition.OUTSIDE)
                    .setMinorTickPosition(Axis.TickPosition.OUTSIDE)
                    .setLineColor("#933")
                    .setTickColor("#933")
                    .setMinorTickColor("#933")
                    .setOffset(-20)
                    .setLineWidth(2)
                    .setTickLength(5)
                    .setMinorTickLength(5)
                    .setEndOnTick(false)
                    .setLabels(
                            new YAxisLabels()
                                    // There is no documented "distance" option for gauge chart axes
                                    .setOption("distance", 12)
                    )
            ;
    
            final Series series = chart.createSeries();
            chart.addSeries(series
                    .setName("Random speed")
                    .addPoint(80)
            );
    
            final Timer tempTimer = new Timer() {
                @Override
                public void run() {
                    long inc = Math.round((Random.nextDouble() - .5) * 20);
                    long cur = series.getPoints()[0].getY().longValue();
                    series.getPoints()[0]
                            .update(cur + inc);
    
                }
            };
    
            tempTimer.scheduleRepeating(2000);
    
            return chart;
        }
    
     
  • b3t

    b3t - 2014-03-12

    @Shawn before asking for a showcase I tried coding to myself, wrt example of Polar charts, but I have the same error when I add the series to the chart:

    00:00:17,254 [ERROR] Uncaught exception escaped
    com.google.gwt.core.client.JavaScriptException: (String) @com.google.gwt.core.client.impl.Impl::apply(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)([JavaScript object(880), JavaScript object(879), JavaScript object(890)]): Highcharts error #17: www.highcharts.com/errors/17     
    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:249)    
    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)    
    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:576)  
    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:284)    
    at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)   
    at com.google.gwt.core.client.impl.Impl.apply(Impl.java)    
    at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:347)   
    at sun.reflect.GeneratedMethodAccessor47.invoke(Unknown Source)     
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)    
    at java.lang.reflect.Method.invoke(Method.java:606)     
    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)    
    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)   
    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)    
    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293)     
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)   
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)     
    at java.lang.Thread.run(Thread.java:744)
    

    Highcharts Error #17: "The requested series type does not exist".

     

    Last edit: b3t 2014-03-15
  • b3t

    b3t - 2014-03-12

    Resolved.
    I forget to add the script tag for "highcharts-more.js" into the HTML file.
    @Shawn thank you very much!

     

    Last edit: b3t 2014-03-12

Log in to post a comment.