【问题标题】:Highcharts - "Style is null or not an object"Highcharts - “样式为空或不是对象”
【发布时间】:2011-03-29 16:04:33
【问题描述】:

所以,我在使用 Highcharts 时遇到了一些问题。它最近出现了一个仅在 Internet Explorer 8 中触发的错误。失败的行来自 highcharts.src.js 文件的第 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...
}

创建图表的代码如下:

$(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函数在webservice调用成功后触发,提供如下Json图表数据:

{"chart": {
  "renderTo":"container0438",
  "zoomType":"xy"},
  "credits": { 
    "enabled": false,
    "position": {
      "align":"right",
      "x":-10,
      "verticalAlign":"bottom",
      "y":-5
  },
  "href":"http:\/\/www.website.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}
}

在其他浏览器中一切正常。有什么想法吗?

谢谢!

【问题讨论】:

  • 你有没有机会把这个放在小提琴里?我隐约记得以前遇到过这个问题,但是查看您正在使用的 html 也会很有帮助。此外,您是否尝试过使用硬编码数据在不调用 Web 服务的情况下复制此内容?

标签: javascript asp.net highcharts


【解决方案1】:

我搞砸了 highcharts,确实记得看到此错误消息,但当时是在 chrome 上进行测试。我发现硬编码我的 json 数据非常有帮助,这些数据将被输入到 highcharts 中,以确保它不是从服务返回的数据。我也会尝试在不必调用destroy的情况下搞乱,而只是想办法重新绘制图表。我知道有人建议销毁图表,但有时这对我来说是个问题。也许只是重用同一个图表实例,chartcontainer1700,然后更改传入的数据,然后重新绘制它。

【讨论】:

    猜你喜欢
    • 2012-11-19
    • 2012-10-13
    • 1970-01-01
    • 1970-01-01
    • 2013-08-30
    • 2011-07-21
    • 1970-01-01
    • 2011-05-01
    • 2013-12-16
    相关资源
    最近更新 更多