Menu

Is it possible to insert JSON code into a chart object with setOption method?

2015-01-28
2015-01-29
  • meisterlampe

    meisterlampe - 2015-01-28

    Hi,

    I know that it is possible to set valeus with the setOption method
    (like chart.setOption("/plotOptions/series/enableMouseTracking", false);

    I am currently trying to insert JSON Methods to my chart object, for example a mouseMove.
    Directly in javascript i got the following structure:

    $('#container').highcharts(
    {
    plotOptions:
    {
    mouseOver: function (e)
    {
    console.log(e);
    }
    }
    }

    when i define a String method="function (e) { console.log(e);} and insert this string with
    setOption("/plotOptions/mouseOver",method);
    to my chart the method is inserted into the chart obejct, but with quotes "function(e)...". And the quoted method wont be executed.

    I think it would work when the quotes are removed, but i dont know how to set the option without a string object.

    Someone got an idear to solve this problem?

    If this would work somehow, it would be easy to use features of Highcharts 4.

    thx

     
  • Shawn Quinn

    Shawn Quinn - 2015-01-29

    As you've found, GWT Highcharts does allow you to add arbitrary data/configuration options to a chart via the "Chart.setOption()", "Axis.setOption()", "Series.setOption()", etc methods. That allows GWT Highcharts to be "future compatible" with many of the new options that are added to Highcharts.js. However, I personally don't know of a way in GWT to chain along a JS function pointer (especially not through JSON) without resorting to JSNI (e.g. similar to what BaseChart.nativeRenderChart() needs to do).

     

Log in to post a comment.