开发者

Highcharts - "Style is null or not an object"

开发者 https://www.devze.com 2023-02-20 09:09 出处:网络
So, I\'m having some issues using Highcharts. It recently came up with an error that only fires up in Internet Explorer 8. The failing line comes up from the highcharts.src.js file line 270:

So, I'm having some issues using Highcharts. It recently came up with an error that only fires up in Internet Explorer 8. The failing line comes up from the highcharts.src.js file line 270:

function css (el, styles) {
  if (isIE) {
    if (styles && styles.opacity !== UNDEFINED) {
      styles.filter = 'alpha(opacity='+ (styles.opacity * 100) +')';
    }
  } 

  extend(el.style, styles); // This line fails...
}

The code that creates the chart is the following:

$(document).ready(function() {
  chartcontainer1700 = new Highcharts.Chart({
    chart: {
      renderTo: 'container1700'
    },
    title: {
      text: 'Loading chart...'
    }
  });
});

function onSuccess(options){
  if (options.hasOwnProperty('restErrorMessage') && options.restErrorMessage != null) {
     alert(options.restErrorMessage);
  }
  chartcontainer1700.destroy();
  chartcontainer1700 = new Highcharts.Chart(options);
  chartcontainer1700.redraw();
};

onSuccess function is fired after a webservice call succeeds to provide the chart data that is a Json as follows:

{"chart": {
  "renderTo":"container0438",
  "zoomType":"xy"},
  "credits": { 
    "enabled": false,
    "position": {
      "align":"right",
      "x":-10,
      "verticalAlign":"bottom",
      "y":-5
  },
  "href":"http:\/\/www.w开发者_运维知识库ebsite.com",
  "text":"Chart"
},
"legend": {
  "borderRadius":0,
  "borderWidth":0,
  "enabled":true
},
"series":[{"data":[67.5,67.75],"name":"ME","type":"spline","yAxis":0}],
"title":{"align":"center","text":""},
"xAxis":[{
  "categories":["Mar 22, 2011 - Mar 26, 2011","Mar 27, 2011 - Mar 29, 2011"],
  "maxPadding":5,"minPadding":1
 }],
 "yAxis":[{
   "labels":{
     "style":{"color":"Gray"}
   },
   "opposite":false,
   "title":{"text":"ME %","style":{"color":"Gray"}},
   "type":"spline"}],
   "exporting":{"enabled":true}
}

Everything works perfect in other browsers. Any thougths?

Thanks!


I've messed around with highcharts and do recall seeing this error message but was testing on chrome. I found it very helpful to just hard code my json data that is going to be fed into highcharts just to make sure it isn't the data being returned from the service. I would also try messing around with not having to call destroy and just finding a way to redraw the chart. I know it is suggested to destroy the chart but it has been problematic for me at times. Maybe just reuse the same instance of chart, chartcontainer1700, and just change the data being passed in, and redrawing it.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号