Charts SVGGenerator fails.


SVGGenerator.getInstance().generate(conf)
always returns “failed” string and hence throws RuntimeException:

Caused by: java.lang.RuntimeException: java.lang.RuntimeException: SVG generation failed!!

However, the demo project from
http://dev.vaadin.com/svn/addons/vaadin-charts/chart-export-demo/
does work.

I added WorldMap charts as described in
https://vaadin.com/forum#!/thread/1808371
.

The export that fails is not the WorldMap but a simple line chart.

How can I debug?

Thank you,

AT.

Hi,

Can you share the Chart configuration that fails? The SVG generation uses only default scripts, so that might cause some issues. We can make that part extendable as well.

Debugging is quite advanced stuff with PhantomJS, see their help pages if you wish to look at this yourself.

cheers,
matti

Matti,

Thanks for the quick reply.
Please find the chart configuration below. I revised the example that you provided in the other charts post and only left the map stuff that’s custom.
I reduced the
HighchartPluginResources
and
HighchartsPluginScriptLoader
to only add scripts to generate map heat charts:


    @Source("com/mindspark/apn/vcs/web/client/world-map-shapes.js")
    TextResource worldMapShapes();

    @Source("com/mindspark/apn/vcs/web/client/map.src.js")
    TextResource mapSrcJs();

and


        inject(HighchartPluginResources.INSTANCE.worldMapShapes().getText());
        inject(HighchartPluginResources.INSTANCE.mapSrcJs().getText());

Everything else is loaded as specified in
HighchartResources
.

The following is the configuration that I use:


{
  "chart": {
    "type": "line",
    "spacingRight": 25,
    "zoomType": "x"
  },
  "title": {
    "floating": true,
    "text": ""
  },
  "xAxis": {
    "type": "datetime",
    "startOnTick": false,
    "showFirstLabel": true,
    "showLastLabel": true,
    "dateTimeLabelFormats": {
      "second": " ",
      "minute": " ",
      "hour": " ",
      "day": "%b %e",
      "week": "%b %e",
      "month": "%b %e"
    },
    "endOnTick": false,
    "axisIndex": 0
  },
  "yAxis": [
    {
      "labels": {
        "_fn_formatter": "function() {return \u0027$\u0027 + $wnd.Highcharts.numberFormat(this.value, 0, \u0027,\u0027);}"
      },
      "title": {
        "text": ""
      },
      "showFirstLabel": true,
      "showLastLabel": true,
      "minPadding": 0.0,
      "axisIndex": 0
    },
    {
      "labels": {
        "_fn_formatter": "function() {return \u0027\u0027 + $wnd.Highcharts.numberFormat(this.value, 0, \u0027,\u0027);}"
      },
      "title": {
        "text": "      ",
        "style": {}
      },
      "showFirstLabel": true,
      "showLastLabel": true,
      "opposite": true,
      "minPadding": 0.0,
      "axisIndex": 1
    }
  ],
  "tooltip": {
    "_fn_formatter": "function() { var unit\u003d\u0027\u0027; if(this.series.name \u003d\u003d \u0027Totals\u0027) unit\u003d\u0027$\u0027; return unit + \u0027\u0027+ $wnd.Highcharts.numberFormat(this.y, 0) +\u0027\u003c/b\u003e\u003cbr/\u003e\u0027+  $wnd.Highcharts.dateFormat(\u0027%A, %b %e, %Y\u0027, this.x);}"
  },
  "legend": {
    "layout": "horizontal",
    "align": "center",
    "verticalAlign": "bottom",
    "floating": false,
    "enabled": false
  },
  "credits": {
    "enabled": false
  },
  "series": [
    {
      "data": [
        {
          "y": 5833.448421534268,
          "x": 1370995200000,
          "marker": {
            "enabled": false
          },
          "customized": true
        },
        {
          "y": 5747.082095542318,
          "x": 1371081600000,
          "marker": {
            "enabled": false
          },
          "customized": true
        },
        {
          "y": 5536.116469663475,
          "x": 1371168000000,
          "marker": {
            "enabled": false
          },
          "customized": true
        },
        {
          "y": 5190.219700764622,
          "x": 1371254400000,
          "marker": {
            "enabled": false
          },
          "customized": true
        },
        {
          "y": 5756.474382025763,
          "x": 1371340800000,
          "marker": {
            "enabled": false
          },
          "customized": true
        },
        {
          "y": 5940.68886995518,
          "x": 1371427200000,
          "marker": {
            "enabled": false
          },
          "customized": true
        },
        {
          "y": 5792.404670910532,
          "x": 1371513600000,
          "marker": {
            "enabled": false
          },
          "customized": true
        },
        {
          "y": 6098.552992630286,
          "x": 1371600000000,
          "marker": {
            "enabled": false
          },
          "customized": true
        }
      ],
      "name": "Totals",
      "visible": true,
      "yAxis": 0,
      "color": "#5FADDA",
      "type": "line"
    },
    {
      "data": [
        {
          "y": 0.0,
          "x": 1370995200000,
          "marker": {
            "enabled": false
          },
          "customized": true
        },
        {
          "y": 0.0,
          "x": 1371081600000,
          "marker": {
            "enabled": false
          },
          "customized": true
        },
        {
          "y": 0.0,
          "x": 1371168000000,
          "marker": {
            "enabled": false
          },
          "customized": true
        },
        {
          "y": 0.0,
          "x": 1371254400000,
          "marker": {
            "enabled": false
          },
          "customized": true
        },
        {
          "y": 0.0,
          "x": 1371340800000,
          "marker": {
            "enabled": false
          },
          "customized": true
        },
        {
          "y": 0.0,
          "x": 1371427200000,
          "marker": {
            "enabled": false
          },
          "customized": true
        },
        {
          "y": 0.0,
          "x": 1371513600000,
          "marker": {
            "enabled": false
          },
          "customized": true
        }
      ],
      "name": "Fake",
      "visible": false,
      "yAxis": 1,
      "color": "#F29408",
      "type": "line"
    }
  ],
  "exporting": {
    "enabled": false
  }
}

Interestingly, if I plugin this configuration into
http://export.highcharts.com/demo
, it generates the image correctly.

Thank you,

AT.

Opened a support request.

Hi,

So it indeed is the issue that your Highcharts extension scripts should be somehow made available for the PhantomJS instance building the SVN. Our support wizards will find a solution or extend the improve the SVG generation API so that this can be done.

cheers,
matti

Is this doable with Rhino instead of PhantomJS? With Rhino you should not need to rely on external executable.

Hi,

It might be doable as some older approach actually used Rhrino. It would though have the exact same issue that you have currently. We chose PhantomJS path at this point as it is currently the one that Highcharts (JS library on which Vaadin Charts is built) also uses and develops further.

Do you have problems installing PhantomJS or just wondering this for convenience?

cheers,
matti

We didn’t have problems installing it. It was a somewhat late realization though. Some companies might not like that. Also the fact that exporting by default goes thru the highcharts servers.

BTW, do you make anything of the fact that when i plugged the configuration into the highcharts exporting demo, it worked?

AT.

I, too, am suffering from the SVGGenerator causing a RuntimeException - but strangely, it only happens to me on MacOSX. When I try to generate the SVG for the same chart on a Linux box it works. The version of phantomjs on both platforms is identical: v1.9.2. I’m running Vaadin Charts 1.1.2 and Vaadin 7.1.6. The full stack trace is below - if anyone has any idea what I might be able to do to track down the problem, I’d appreciate it.

Oct 10, 2013 9:57:54 PM com.vaadin.server.DefaultErrorHandler doDefault
SEVERE:
com.vaadin.server.ServerRpcManager$RpcInvocationException: Unable to invoke method click in com.vaadin.shared.ui.button.ButtonServerRpc
at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:170)
at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:118)
at com.vaadin.server.communication.ServerRpcHandler.handleBurst(ServerRpcHandler.java:214)
at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:111)
at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:91)
at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:37)
at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1371)
at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:238)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.blackstratus.reports.ResourcesFilter.doFilter(ResourcesFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:168)
… 27 more
Caused by: com.vaadin.event.ListenerMethod$MethodException: Invocation of method buttonClick in com.blackstratus.reports.ExportWindow$1 failed.
at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:528)
at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:167)
at com.vaadin.server.AbstractClientConnector.fireEvent(AbstractClientConnector.java:969)
at com.vaadin.ui.Button.fireClick(Button.java:368)
at com.vaadin.ui.Button$1.click(Button.java:57)
… 32 more
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: SVG generation failed!!
at com.vaadin.addon.charts.util.SVGGenerator.generate(SVGGenerator.java:193)
at com.vaadin.addon.charts.util.SVGGenerator.generate(SVGGenerator.java:162)
at com.blackstratus.reports.ExportWindow.createStream(ExportWindow.java:97)
at com.blackstratus.reports.ExportWindow.access$000(ExportWindow.java:36)
at com.blackstratus.reports.ExportWindow$1.buttonClick(ExportWindow.java:72)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:508)
… 36 more
Caused by: java.lang.RuntimeException: SVG generation failed!!
at com.vaadin.addon.charts.util.SVGGenerator.generate(SVGGenerator.java:189)
… 45 more

Does the SVGGenerator work with Vaadin 6 ?