【问题标题】:No jqPlot-plugin is working in IE没有 jqPlot 插件在 IE 中工作
【发布时间】:2011-09-06 14:00:04
【问题描述】:

我正在使用 jqPlot 绘制一些简单的折线图,它在 Chrome 中效果很好。但是在每个版本的 IE(包括 9)中,jqPlot 插件都不起作用。我已经尝试过pointLabels、dateAxisRenderer 和highlighter 插件,但它们没有任何效果。

我的代码与 jqPlot 网站上的示例几乎相同。我知道的唯一区别是我通过 JavaScript 为图表动态创建了 div 元素占位符。

这是我用来创建图表的代码:

 scurve_chart = $.jqplot('cv', [line1], {
            title: 'distribute costs',
            seriesDefaults: { 
                showMarker:false,
                pointLabels: { show: true, location: 's', ypadding: 3 }
            },
            axes: {
                xaxis: {
                    min: 0.5,
                    tickOptions: {
                        formatString: '%.0f'
                    }
                },
                yaxis: {
                    max: Math.round(max_value_to_dist * 1.10),
                    min: 0,
                    tickOptions: {
                        formatString: '%.0f'
                    }
                }
            }
        });

我用的是最新版的jqplot和jquery-1.4.1

//更新:解决方案

问题是我直接从 jqplot 主页包含了所有插件文件。例如: <script type="text/javascript" src="http://www.jqplot.com/src/plugins/jqplot.dateAxisRenderer.min.js"></script>

好像 IE 不喜欢那样。

【问题讨论】:

  • 如果下面的答案没有帮助,您是否还可以显示用于创建 DIV 占位符的代码

标签: jquery internet-explorer plugins jqplot


【解决方案1】:

您忽略了在您提供的示例代码中显示您的包含 - 它是否在 IE 中绘制了任何内容,或者它绘制了基本的折线图但不使用渲染器?

对于 IE,您需要包含以下行(确保 excanvas.js 的路径指向包含您的 jqplot.js 的同一目录)

<!--[if IE]><script type="text/javascript" src="../excanvas.js">
            </script><![endif]-->

此外,对于每个插件,还需要添加另一个包含,例如对于调酒师

<script type="text/javascript" src="../plugins/jqplot.barRenderer.min.js">
</script>

再次使用为 .js 文件指定的正确路径

如果您指定了路径,请检查它们是否列在包含 $(document).ready(function() 的标记之前,并确保所有 .css 文件在开始时都已加载。

【讨论】:

  • 我发现了问题(请参阅更新的问题)。由于您暗示脚本标签可能有问题的提示非常好-我认为您的回答值得接受。
  • 每个人都喜欢微​​软对吧? - 它们让 Web 开发人员的生活变得如此轻松......哈哈
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-05-28
  • 1970-01-01
  • 2023-03-26
  • 2015-03-13
  • 1970-01-01
  • 2011-09-05
  • 1970-01-01
相关资源
最近更新 更多