【问题标题】:Unwanted line on barchart with jqplot带有 jqplot 的条形图上不需要的线
【发布时间】:2013-09-11 02:35:41
【问题描述】:

我有一个条形图,上面有我在 stackoverflow 上找到的一些示例代码。这是图表的代码:

var axisDates = ["Jan 19", "Jan 20", "Jan 21"]
var chartData = [2.61, 5.00, 6.00]

$.jqplot.config.enablePlugins = true;
var plot2 = $.jqplot('SubScoresGraph', [chartData], {
    title: 'Some Plot',
    seriesDefaults: {
        renderer: $.jqplot.BarRenderer,
        rendererOptions: {
            barPadding: 1,
            barMargin: 15,
            barDirection: 'vertical',
            barWidth: 50
        },
        pointLabels: { show: true }
    },
    axes: {
        xaxis: {
            renderer: $.jqplot.CategoryAxisRenderer,
            ticks: axisDates
        },
        yaxis: {
            tickOptions: {
                formatString: '$%.2f'
            }
        }
    },
    highlighter: {
        sizeAdjust: 7.5
    },
    cursor: {
        show: true
    }
});

在我的页面上,我包含 jquery 1.9.1 和最新版本的 jqplot。我有一个带有 jqplot 的 .js 文件,后跟所有插件文件中的代码。所以本质上它是将所有的 jqplot javascript 合并到一个文件中。

<script src="jquery-1.9.1.js"></script>
<script src="combined.js"></script>

不过,出于某种原因,我的图表中出现了一条线,但我不知道为什么。我在我的代码中找不到任何明显的东西,当我在 jsfiddle 中尝试它时,它会在没有线条的情况下呈现。

【问题讨论】:

    标签: javascript jquery charts jqplot


    【解决方案1】:

    由于您已包含所有 jqplot 插件,因此您已包含 Trendline 插件。当您设置$.jqplot.config.enablePlugins = true; 时,它会将趋势线设置为默认显示。您必须明确将 show 设置为 false。

    在您的 seriesDefaults 块内,添加:

    trendline: {
      show: false
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多