Menu

Uncaught TypeError: Cannot read property 'length' of undefined

8020Rule
2012-06-18
2012-07-05
  • 8020Rule

    8020Rule - 2012-06-18

    I'm trying to setup a master-detail chart and can't get the Plot Bands to work. The error I get is: Uncaught TypeError: Cannot read property 'length' of undefined. I've tried using purely Java code to create a PlotBand and configure it and then set it on the axis. No dice. I tried using the Axis' setOption method to set a PlotBand on the Axis. No dice. Is this a bug or am I missing something.

     
  • 8020Rule

    8020Rule - 2012-06-19

    The following code snippet is my latest attempt to configure the X Axis' PlotBands. I've also tried creating a single PlotBand and setting it on the Axis. This time around I created an array as the PlotBands property expects an array. The PlotBand is configured to go from the middle of the Series to the end.

    Point[] mcPoints = masterChart.getSeries()[0].getPoints();
    
    Color color = new Color();
    color.setLinearGradient(0, 0, 0, .2);
    
    PlotBand[] mcPlotBands = new PlotBand[2];
    mcPlotBands[0] = mcXAxis.createPlotBand();
    mcPlotBands[0].setOption("/plotBands/id", "before-band");
    mcPlotBands[0].setFrom(mcPoints[12].getX());
    mcPlotBands[0].setTo(mcPoints[47].getX());
    mcPlotBands[0].setColor(color);
    mcXAxis.setPlotBands(mcPlotBands);
    
     
  • 8020Rule

    8020Rule - 2012-06-19

    In my previous post, I didn't state that the same error is getting thrown and the chart is rendering incorrectly.

     
  • Shawn Quinn

    Shawn Quinn - 2012-07-05

    That sounds like a native Highcharts issue, although I can't tell for sure without a full example that shows the error (maybe the plot band label is required? I also just noticed in your code example there that you're creating an array of 2 PlotBand instances, but only the first of the two is getting populated).

    Note that there's a functional example that show plot bands working here that you could also consider starting with if it helps:

    http://www.moxiegroup.com/moxieapps/gwt-highcharts/showcase/#line-spline-plotbands

     

Log in to post a comment.