【问题标题】:jqplot - Want to restrict y axis ticksjqplot - 想要限制 y 轴刻度
【发布时间】:2014-06-10 18:17:17
【问题描述】:

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

        $(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"]
});
});

【问题讨论】:

    标签: javascript css jqplot


    【解决方案1】:

    您必须删除 axesDefaults 中的 tickInterval 选项以让 jqplot 计算他自己的刻度,或者在 axesDefaults 中添加 numberTicks 选项以告诉 jqplot 绘制 x 刻度其中 x 是赋予 numberTicks 选项的数字。

    • 如果您使用 axesDefaults:{min:0, tickInterval:1},jqplot 将以 1 个单位的间隔绘制从 0 到最大值的刻度(从 0 到 82 的 80 多个刻度) .
    • 如果您使用 axesDefaults:{min:0},jqplot 将绘制从 0 到最大值的 5 个刻度(默认情况下),计算两个刻度之间的相同间隙。
    • 如果使用 axesDefaults:{min:0, tickInterval:1, numberTicks:15},jqplot 将从 0 开始绘制 15 个刻度,间隔为 1 个单位(从 0 到 15 个刻度14).
    • 如果您使用 axesDefaults:{min:0, numberTicks:15},jqplot 将从 0 到最大值绘制 15 个刻度,计算两个刻度之间的相同间隙。

    选择最适合的选项。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多