【问题标题】:jqplot.CanvasAxisTickRenderer throws Uncaught TypeErrorjqplot.CanvasAxisTickRenderer 抛出 Uncaught TypeError
【发布时间】:2014-06-18 23:32:00
【问题描述】:

我正在使用 jqplot 来显示我的条形字符。

在我添加 tickRenderer 和 tickOptions 之前,条形图工作正常。

现在我收到以下错误:Uncaught TypeError: undefined is not a function

这是我的代码

plot3 = $.jqplot('chart3', [s2, s3], {
    stackSeries: true,
    seriesDefaults: {
        renderer: $.jqplot.BarRenderer,
        rendererOptions: {
            highlightMouseDown: true
        },
        pointLabels: {show: true}
    },
    legend: {
        show: true,
        location: 'e',
        placement: 'outside'
    },
    axes: {
        xaxis: {
            renderer: $.jqplot.CategoryAxisRenderer,
            ticks: ticks,
            tickRenderer: $.jqplot.CanvasAxisTickRenderer ,
            tickOptions: {
                angle: -90,
                fontSize: '10pt'
            }
        }
    }
});

【问题讨论】:

    标签: jquery jqplot


    【解决方案1】:

    我正在动态加载我的脚本,但我的 loadScript() 函数是异步的,因此在绘制图表之前并非所有资源都已加载。将 async 更改为 false 后,一切都开始工作了。

    loadScript("jqplot/jquery.jqplot.min.js");
    loadScript("jqplot/jqplot.dateAxisRenderer.min.js");
    loadScript("jqplot/jqplot.barRenderer.min.js");
    loadScript("jqplot/jqplot.canvasTextRenderer.min.js");
    loadScript("jqplot/jqplot.canvasAxisTickRenderer.min.js");
    loadScript("jqplot/jqplot.categoryAxisRenderer.min.js");
    loadScript("jqplot/jqplot.pointLabels.min.js");
    
    function loadScript(jsPage) {
        $.ajax({
            url: jsPage,
            async: false,
            dataType: "script"
        });
    }
    

    【讨论】:

      【解决方案2】:

      我试过你的代码,它工作... 我不知道你的问题是什么。

      我包含了这些插件

      <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
      <script type="text/javascript" src="http://cdn.jsdelivr.net/jqplot/1.0.8/jquery.jqplot.min.js"></script>
      <link rel="stylesheet" type="text/css" href="http://cdn.jsdelivr.net/jqplot/1.0.8/jquery.jqplot.min.css" />
      <script type="text/javascript" src="http://cdn.jsdelivr.net/jqplot/1.0.8/plugins/jqplot.barRenderer.min.js"></script>
      <script type="text/javascript" src="http://cdn.jsdelivr.net/jqplot/1.0.8/plugins/jqplot.categoryAxisRenderer.min.js"></script>
      <script type="text/javascript" src="http://cdn.jsdelivr.net/jqplot/1.0.8/plugins/jqplot.pointLabels.min.js"></script>
      <script type="text/javascript" src="http://cdn.jsdelivr.net/jqplot/1.0.8/plugins/jqplot.cursor.min.js"></script>
      

      我使用这些数据数组进行测试。

      $(document).ready(function(){
       s2 = [0,1,2,3,4];
       s3 = [1,2,3,4,5];
       ticks = ["a","b","c","d","e"];
      

      这是结果

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-10-14
        • 1970-01-01
        • 2023-03-04
        • 2021-01-07
        • 2015-10-21
        • 1970-01-01
        • 1970-01-01
        • 2013-02-11
        相关资源
        最近更新 更多