2013-10-25 49 views
0

我正在使用jqplot繪製餅圖,條形圖和折線圖。它在IE9> =中工作正常。但它不適用於IE8。當我使用餅圖和條形圖時,它給了我上述錯誤。並且它在e.jqplot.PieRenderer'的piechart插件處顯示錯誤。阻止這個插件條形圖工作正常,但不是餅圖。以下是我的代碼。請在此建議。無法獲取屬性「渲染器」的值:對象爲空或未定義:Jqplot

var optionsObj = { 
      title: 'Item wise stock', 
      animate: !$.jqplot.use_excanvas, 
      axes: { 
       xaxis: { 
        renderer: $.jqplot.CategoryAxisRenderer, 
        ticks: dates, 
        label: 'Item' 
       }, 
       yaxis: { 
        tickOptions: { showMark: true, formatString: "%d" }, 
        padMin: 0, 
        label: 'Stock', 
        angle: -30, 
        labelRenderer: $.jqplot.CanvasAxisLabelRenderer, 
        labelOptions: { fontSize: '11px' } 
       } 
      }, 

      grid: { 
       drawGridLines: true,  // wether to draw lines across the grid or not. 
       gridLineColor: '#cccccc', // *Color of the grid lines. 
       background: '#e6e6e6',  // CSS color spec for background color of grid. 
       borderColor: '#999999',  // CSS color spec for border around grid. 
       borderWidth: 2.0,   // pixel width of border around grid. 
       shadow: true,    // draw a shadow for grid. 
       shadowAngle: 45,   // angle of the shadow. Clockwise from x axis. 
       shadowOffset: 1.5,   // offset from the line of the shadow. 
       shadowWidth: 3,    // width of the stroke for the shadow. 
       shadowDepth: 3,    // Number of strokes to make when drawing shadow. 
       // Each stroke offset by shadowOffset from the last. 
       shadowAlpha: 0.07,   // Opacity of the shadow 
       renderer: $.jqplot.CanvasGridRenderer, // renderer to use to draw the grid. 
       rendererOptions: {}   // options to pass to the renderer. Note, the default 
       // CanvasGridRenderer takes no additional options. 
      }, 

      series: [ 
       { label: 'Bar', renderer: $.jqplot.BarRenderer }, 
       { label: 'Line', renderer: $.jqplot.LineRenderer, color: '#ef8c08' }, 
       ], 

      legend: { 
       show: true, 
       location: 'ne' 
      }, 
      seriesDefaults: { 
       shadow: false, 
       rendererOptions: { 
        barPadding: 0, 
        barMargin: 10, 
        barWidth: 25, 
        highlightMouseDown: true 
       } 
      }, 
      highlighter: { 
       show: true, 
       sizeAdjust: 7.5, 
       tooltipContentEditor: function (str, seriesIndex, pointIndex, jqPlot) { 

        return '<table class="jqplot-highlighter"><tr><td>Item:</td><td>' + data[pointIndex][0].toString() + '</td></tr> \ 
        <tr><td>Stock:</td><td>' + data[pointIndex][1].toString() + '</td></tr></table>' 

       } 

      } 
     }; 

     var plot2 = $.jqplot(location, values, optionsObj); 
+0

只是把我的頭,爲什麼ü用柱狀圖和餅狀在一起的頂部。我無法理解你對它的期望是什麼樣的輸出? – Gyandeep

+0

這些是在一個頁面上的獨立圖形。 –

+0

你能分享jsfiddle eaxple什麼是輸出 – Gyandeep

回答

1

在HTML頁面本文標籤:

<script type='text/javascript' src="excanvas.js"></script> 

IE8需要excanvas庫創建畫布元素,因爲IE8 doen't支持帆布元素。

你可以從這裏下載js文件:Excanvas library

+0

我已經包含了這個。 –

+0

確保這是包含的第一個文件。你的錯誤只是因爲這個。我100%確定,因爲我測試了你的代碼。 – Gyandeep

+0

這適用於我,適用於IE7> Edge。 – chris

相關問題