1

我正在尝试在我正在处理的报告页面上制作一个简单的饼图。我的客户在他们的所有系统中都使用 IE8。RGraph 提供了我认为最好的绘图工具,它是我老板要求我使用的绘图工具。所以没有改变说服我。
我也在使用 asp.net

<script type="text/javascript" src="/js/RGraph/libraries/RGraph.common.key.js"></script>
<script type="text/javascript" src="/js/RGraph/libraries/RGraph.drawing.rect.js"></script>
<script type="text/javascript" src="/js/RGraph/libraries/RGraph.common.core.js"></script>
<script type="text/javascript" src="/js/RGraph/libraries/RGraph.common.dynamic.js"></script>
<script type="text/javascript" src="/js/RGraph/libraries/RGraph.common.tooltips.js"></script>
<script type="text/javascript" src="/js/RGraph/librarieslibraries/RGraph.pie.js"></script>
<!--[if lt IE 9]><script src="/js/RGraph/excanvas/excanvas.js"></script><![endif]-->

<script type="text/javascript">
    function renderMap() {
        <%= GetPie() %>;
    }
   $(document).ready(function () {
        renderMap();
    });
 </script>

和我的画布

  <canvas id="myPie" width="500" height="300">[No Canvas Support]</canvas>

和我的 .net 后面的代码部分

protected string GetCounts()
{
  // cut out code //
  //  var longs = [1,2,3,4] 
  //  var names = ["program1", "program2", "program3", "program4"]
  //  var precents = ["1.2%", "1.3%", "1.4%", "1.5%"]
  //  these values are hard coded on here not on my page
  // its for my clients protection that i use false data

    StringBuilder output = new StringBuilder();
    output.Append("var pie = new RGraph.Pie('myPie', [");
    output.Append(TotalEmployeeList.Count - totalOfthese + ", ");
    output.Append(longs);
    output.Append("])");
    output.Append(".Set('labels', [");
    output.Append("\"" + GetPercent(Utility.ToDouble(TotalEmployeeList.Count - totalOfthese)) + " Unqualified\", ");
    output.Append(percent);
    output.Append("])");
    output.Append(".Set('labels.sticks', [true])");
    output.Append(".Set('labels.sticks.length', 20)");
    output.Append(".Set('key', ['Unqualified',");
    output.Append(names);
    output.Append("])");
    output.Append(".Set('key.colors', ['#a7a8aa','#003057','#009fdf','#e87722','#a7a8aa','#003057', '#009fdf'])");
    output.Append(".Set('key.interactive', true)");
    output.Append(".Set('key.position', 'gutter')");
    output.Append(".Set('key.position.y', 275)");
    output.Append(".Set('key.rounded', false)");
    output.Append(".Set('colors', ['#a7a8aa','#003057','#009fdf','#e87722','#a7a8aa','#003057','#009fdf'])");
    output.Append(".Set('strokestyle', 'white')");
    output.Append(".Set('linewidth', 3)");
    output.Append(".Set('shadow', true)");
    output.Append(".Set('shadow.offsetx', 2)");
    output.Append(".Set('shadow.offsety', 2)");
    output.Append(".Set('shadow.blur', 3)");
    output.Append(".Set('exploded', 7)");
    output.Append(".Set('chart.radius', 100)");
    output.Append(".Set('origin', 0)");
    output.Append(".Draw();");

    return output.ToString();
}

我的问题是密钥和饼图在所有浏览器中都有效,但不是 ie 8 .. 部分在 ie 9 中。有什么我遗漏的吗?那会阻止IE正常工作吗?

4

1 回答 1

0

从外观上看,您没有使用 window.onload 函数来创建图表 - 我注意到 ExCanvas 似乎需要它。例如:

window.onload = function (e)
{
    // Create chart here (NB: the bar variable must be declared using the var keyword)

    var bar = new RGraph.Bar('cvs', [4,8,6,3,5,2,4]);
    bar.Draw();
}
于 2013-08-23T13:54:50.633 回答