jqplot-极限点标签仅显示为1系列 [英] jqplot - Limiting point labels displayed to just 1 series

查看:94
本文介绍了jqplot-极限点标签仅显示为1系列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用jqPlot,可以将点标签限制为一个系列吗?请看下面的截图!我想显示的只是实际"栏上方的值. 均值"和计划中"不应该显示!

using jqPlot, is it possible to limit the point labels to just one series? See screenshot below! What I would like displayed is just the values above the "Actual" bar. The "mean" and "Planned" should'nt display!

谢谢!

这是我的代码

    <script type="text/javascript">
        $(document).ready(function () {

        $.jqplot.config.enablePlugins = true;

        var trendline = [60000, 70000, 110000, 80000];
        var planned = [70000, 90000, 120000, 100000,];
        var actual = [80000, 80000, 150000, 120000];
        var xAxis = ['Jan', 'Feb', 'Mar', 'Apr'];

        $(function() {  
            $.jqplot('chartDiv', [planned, actual, trendline], BarChart());
        });


        function BarChart()
        {
            var optionsObj = {
                title: '',
                axes: {
                     xaxis: {
                        renderer: $.jqplot.CategoryAxisRenderer,
                        ticks: xAxis,                
                    },
                    yaxis: {
                        tickOptions: { showMark: false, formatString: "%'d" },                       
                    },
                },

                legend: {
                    show: true,
                }, 

                grid: { 
                    borderColor: "#dad5d1",
                    background: "#dad5d1",
                    drawGridlines: false,
                    shadow: false
                },

                series: [

                    {label:'Planned',renderer:$.jqplot.BarRenderer},
                    {label: 'Actual',renderer:$.jqplot.BarRenderer},
                        {label: 'Mean',


                    pointLabels: {
                        show: true,
                        },

                        renderer:$.jqplot.LineRenderer,
                            lineWidth:4,
                            markerOptions:{
                                color: "#d87d12",
                                size:12,
                        }}
                    ],

                seriesColors: [ "#ada195", "#4a4541", "#ff9619"],

                seriesDefaults:{
                    shadow: false,

                    rendererOptions:{
                       barPadding: 0,
                       barMargin: 10,
                       barWidth: 25
                   }

                },  
            };
            return optionsObj;
        }
});

</script>

推荐答案

这实际上看起来像是点标签插件中的错误.您可以通过禁用seriesDefault(show:false)中的值,然后为所需的序列打开它们的值来解决此问题:

This actually looks like a bug in the point labels plugin. You can work around it by disabling the values in the seriesDefault (show:false) and then turning them on for the series you desire:

          series: [
             {label:'Planned',renderer:$.jqplot.BarRenderer},
             {label: 'Actual',renderer:$.jqplot.BarRenderer},
             {label: 'Mean',
              pointLabels: {
                show: true,
              },
              renderer:$.jqplot.LineRenderer,
                lineWidth:4,
                markerOptions:{
                  color: "#d87d12",
                  size:12,
              }}
           ],


           seriesDefaults:{
                pointLabels:{show:false},                    
                shadow: false,
                rendererOptions:{
                   barPadding: 0,
                   barMargin: 10,
                   barWidth: 25
               }
            }, 

这篇关于jqplot-极限点标签仅显示为1系列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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