删除Jqplot堆叠条形图上的零值点标签 [英] Removing zero value point lables on a Jqplot stacked bar chart

查看:125
本文介绍了删除Jqplot堆叠条形图上的零值点标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法删除Jqplot堆叠条形图中的零(点标签).我尝试了"hideZero",但它根本无法正常工作.

I am having trouble removing the zeros (point lables) in a Jqplot stacked bar chart. I tried 'hideZero', but it's not working at all.

我尝试了不同的事情;不知道怎么了.我已经导入了以下软件包:

I tried different things; not sure what's wrong. I have imported the following packages:

jqplot.barRenderer.min.js
jqplot.canvasAxisLabelRenderer.min.js
jqplot.canvasAxisTickRenderer.min.js
jqplot.canvasTextRenderer.min.js
jqplot.categoryAxisRenderer.min.js
jqplot.pointLabels.min.js
jquery-2.0.3.js
jquery.jqplot.min.css
jquery.jqplot.min.js

这是JavaScript:

Here is the JavaScript:

var s3 = [11, 28, 22, 47, 11, 11];
var s1 = [0, 6, 3, 0, 0, 0];
var s2 = [1, 0, 3, 0, 0, 0];
var dataArray = [s3, s1, s2];
var ticks = ['John', 'Tumm', 'Wen', 'Ken', 'Dolly'];

var options = {
    title: 'Title ',
    stackSeries: true,
    seriesColors: ["#eb4b3d", "#ffc800", "#009149"],
    seriesDefaults: {
        renderer: $.jqplot.BarRenderer,
        pointLabels: {
            show: true
        },
        rendererOptions: {
            barWidth: 25,
            varyBarColor: true,
        },
    },
    axes: {
        xaxis: {
            // renderer: $.jqplot.CategoryAxisRenderer,
            //  
            renderer: $.jqplot.CategoryAxisRenderer,
            ticks: ticks,
        },
        yaxis: {
            //autoscale: true,
            //label: 'Application Count',
            min: 0,
            tickInterval: 5,
            max: 50
        }
    },
    axesDefaults: {
        tickRenderer: $.jqplot.CanvasAxisTickRenderer,
        tickOptions: {
            angle: -30,
            fontSize: '10pt'
        }
    }
};

var plot = $.jqplot('chartDivId', dataArray, options);

HTML:

<div id="chartDivId"/>

有一个 JSF这个问题的中端 .

推荐答案

查找有关如何操作的文档的最佳位置是

The best place to look for documentation on how to do things is the API Documentation. It has documentation on each component and plugin and the options available for each. [Restated here and at the top of the answer because I only just added the link.]

点标签的文档位于以下插件的API文档中:

Documentation for the point labels is in the plugin API documentation for : PointLabels (plugins/jqplot.pointLabels.js).

您可以通过添加属性hideZeros: true来删除零值标签.这意味着要更改:

You can remove the zero value labels by adding the property hideZeros: true. This means changing:

        pointLabels: {
            show: true,
        },

收件人:

        pointLabels: {
            show: true,
            hideZeros: true
        },

有一个 正在使用JSFiddle .

完整的JavaScript:

The full JavaScript:

var s3 = [11, 28, 22, 47, 11, 11];
var s1 = [0, 6, 3, 0, 0, 0];
var s2 = [1, 0, 3, 0, 0, 0];
var dataArray = [s3, s1, s2];
var ticks = ['John', 'Tumm', 'Wen', 'Ken', 'Dolly'];

var options = {
    title: 'Title ',
    stackSeries: true,
    seriesColors: ["#eb4b3d", "#ffc800", "#009149"],
    seriesDefaults: {
        renderer: $.jqplot.BarRenderer,
        pointLabels: {
            show: true,
            hideZeros: true
        },
        rendererOptions: {
            barWidth: 25,
            varyBarColor: true,
        },
    },
    axes: {
        xaxis: {
            // renderer: $.jqplot.CategoryAxisRenderer,
            //  
            renderer: $.jqplot.CategoryAxisRenderer,
            ticks: ticks,
        },
        yaxis: {
            //autoscale: true,
            //label: 'Application Count',
            min: 0,
            tickInterval: 5,
            max: 50
        }
    },
    axesDefaults: {
        tickRenderer: $.jqplot.CanvasAxisTickRenderer,
        tickOptions: {
            angle: -30,
            fontSize: '10pt'
        }
    }
};

var plot = $.jqplot('chartDivId', dataArray, options);

HTML:

<div id="chartDivId"/>

这篇关于删除Jqplot堆叠条形图上的零值点标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆