jqplot-要限制y轴刻度 [英] jqplot - Want to restrict y axis ticks

查看:74
本文介绍了jqplot-要限制y轴刻度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在下面的代码中,y轴值不可读,我猜想它是重叠的. 如何设置合适的y轴刻度范围:

In below code y axis values are not readable, I guess its overlapping. How to set suitable y axis tick range:

        $(document).ready(function(){
            var line1 = [82,82];
            var line2 = [22,22];
            var line3 = [0,0];


 var ticks = [1,2];$.jqplot('line', [line1, line2, line3], {
    animate: true,
    axesDefaults:{min:0,tickInterval: 1},        
    seriesDefaults: {
        rendererOptions: {
            smooth: true
        }
    },
    series: [{lineWidth: 1.5, label: 'Passed'},
        {lineWidth: 1.5, label: 'Failed'},
        {lineWidth: 1.5, label: 'Skipped'}],
    axes: {
        xaxis: {
            label: "Run Number",
            ticks: ticks,
            tickOptions: {

                formatString: "%'d Run"

            },
            pad: 1.2,
            rendererOptions: {
                tickInset: 0.3,
                minorTicks: 1
            }
        },
        yaxis: {

            label: "TC Number me"

            ,tickOptions: {
                formatString: "%'d Tc"
                },
        }
    },
    highlighter: {
        show: true,
        sizeAdjust: 10,
        tooltipLocation: 'n',
        tooltipAxes: 'y',
        tooltipFormatString: '%d :&nbsp;<b><i><span style="color:black;">Test Cases</span></i></b>',
        useAxesFormatters: false
    },
    cursor: {
        show: true
    },
    grid: {background: '#ffffff', drawGridLines: true, gridLineColor: '#cccccc', borderColor: '#cccccc',
        borderWidth: 0.5, shadow: false},
    legend: {show: true, placement: 'outside', location: 'e'},
    seriesColors: ["#7BB661", "#E03C31", "#21ABCD"]
});
});

推荐答案

您必须在axes中删除 tickInterval 选项.默认值是让jqplot计算自己的刻度,或添加 numberTicks 选项是默认值,用于告诉jqplot绘制x刻度,其中x是指定给numberTicks选项的数字.

You have either to remove the tickInterval option in axesDefaults to let jqplot computes his own ticks or add the numberTicks option in axesDefaults in order to tell jqplot to draw x ticks where x is the number given to the numberTicks option.

  • 如果您使用 axesDefaults:{min:0,tickInterval:1} ,则jqplot将以0为单位绘制从0到最大值的刻度(从80到0到82的刻度)
  • 如果您使用 axesDefaults:{min:0} ,jqplot将在0至最大值之间绘制5个刻度(默认情况下),并计算两个刻度之间的间隔.
  • 如果您使用 axesDefaults:{min:0,tickInterval:1,numberTicks:15} ,jqplot将绘制15个从0开始的刻度线,间隔为1个单位(从0到15个刻度线) 14).
  • 如果您使用 axesDefaults:{min:0,numberTicks:15} ,则jqplot将绘制从0到最大值的15个刻度,计算两个刻度之间的间隔.
  • If you use axesDefaults:{min:0, tickInterval:1}, jqplot will draw ticks from 0 to your maximal value with an interval of 1 unit (80+ ticks from 0 to 82).
  • If you use axesDefaults:{min:0}, jqplot will draw 5 ticks (by default) from 0 to your maximal value computing a same gap between two ticks.
  • If you use axesDefaults:{min:0, tickInterval:1, numberTicks:15}, jqplot will draw 15 ticks starting at 0 and with an interval of 1 unit (15 ticks from 0 to 14).
  • If you use axesDefaults:{min:0, numberTicks:15}, jqplot will draw 15 ticks from 0 to your maximal value computing a same gap between two ticks.

选择最合适的选项.

这篇关于jqplot-要限制y轴刻度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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