【问题标题】:My Jqplot pie chart is being displayed without any color for the small table inside the pie chart我的 Jqplot 饼图显示为饼图中的小表格没有任何颜色
【发布时间】:2012-11-10 07:20:58
【问题描述】:

我在我的 asp.net MVC 3 Web 应用程序中使用 Jqplot 饼图,但问题是饼图中包含图表标签的小表格没有任何颜色显示。 那么我该如何解决这个问题呢? 提前感谢您的帮助。 BR

编辑

感谢您的友好回复,是的,我已包含这些文件,但仍然没有显示颜色。这是我的 MVC 3 asp.net Web 应用程序中的代码(饼图显示了两个值;喜欢测试的学生与未提供任何评分的学生的百分比)。

<script src="../../Scripts/jqplot/jquery.jqplot.min.js" type="text/javascript"></script>
<script src="../../Scripts/jqplot/jqplot.pieRenderer.min.js" type="text/javascript"></script>
<script src="../../Scripts/jqplot/jqplot.donutRenderer.min.js" type="text/javascript"></script>
<script src="../../Scripts/jqplot/jqplot.barRenderer.min.js" type="text/javascript"></script>
<script src="../../Scripts/jqplot/jqplot.categoryAxisRenderer.min.js" type="text/javascript"></script>
<script src="../../Scripts/jqplot/jqplot.pointLabels.min.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        var data = [
                 ['Number of Like', @ViewBag.CountRate], ['Other', @ViewBag.other]
                   ];
        var plot1 = jQuery.jqplot('r1', [data],
    {
        seriesDefaults: {
            renderer: jQuery.jqplot.PieRenderer,
            rendererOptions: {
                showDataLabels: true
            }
        },
        legend: { show: true, location: 'e' }
    }
  );
    });
</script>

 <div id = "r1"></div>

【问题讨论】:

  • 我也有同样的问题。你最后想通了吗?

标签: javascript asp.net-mvc-3 jqplot


【解决方案1】:

jqPlot documentation 没有很强烈地提到它,但它确实提到了包含 css 文件

要使用 jqPlot 包括 jquery、jqPlot jQuery 插件、jqPlot css 文件和可选的 excanvas 脚本,用于在您的 Web 中支持 IE 页面

所以你需要包括jquery.jqplot.min.css 例如

<link rel="stylesheet" href="/jqplot/jquery.jqplot.min.css">

jqPlot 还建议使用 css 自定义颜色等,请参阅http://www.jqplot.com/docs/files/jqPlotCssStyling-txt.html

【讨论】:

    【解决方案2】:

    您是否正在加载所有必需的 js 文件?听起来你好像不见了:

    jqplot.pointLabels.min.js
    

    添加这些:

    ("~/scripts/jqPlot/jquery.jqplot.min.js")
    ("~/scripts/jqPlot/plugins/jqplot.pieRenderer.min.js")
    ("~/scripts/jqPlot/plugins/jqplot.donutRenderer.min.js")
    ("~/scripts/jqPlot/plugins/jqplot.barRenderer.min.js")
    ("~/scripts/jqPlot/plugins/jqplot.categoryAxisRenderer.min.js")
    ("~/scripts/jqPlot/plugins/jqplot.pointLabels.min.js")
    

    【讨论】:

    • 谢谢;是的,我已经包含了这些文件,但仍然不会显示颜色。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-06
    • 1970-01-01
    相关资源
    最近更新 更多