jq图-获取线性x轴刻度 [英] jq plot - getting linear x axis ticks

查看:103
本文介绍了jq图-获取线性x轴刻度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个jqPlot图表,如下图所示.

I have a jqPlot chart which is rendered as in the image below.

我在x轴上使用LinearAxisRenderer.

Iam using LinearAxisRenderer for the x-axis.

但是x轴的值为0,1、2、2等.

But the x-axis values are coming as 0 ,1,1,2,2, etc..

有没有一种方法可以获取值为0、1、2、3等.

Is there a way to get the values as 0, 1,2,3 etc..

谢谢.

代码:

 $.jqplot(ctrlId, [graphPt], {
        title: chartTitle,
        seriesDefaults: {
            renderer: $.jqplot.BarRenderer,
            pointLabels: { show: true, location: 'e', edgeTolerance: -15, formatString: '%s' },
            shadow: false,
            rendererOptions: {
                barDirection: 'horizontal',
                barMargin: 2
            }
        },
        axesDefaults: {
            renderer: $.jqplot.canvasAxisTickRenderer,
            min: 0,      // minimum numerical value of the axis.  Determined automatically.
            pad: 1.3,       // a factor multiplied by the data range on the axis to give the
            // axis range so that data points don't fall on the edges of the axis.

            tickOptions: {
                mark: 'outside',    // Where to put the tick mark on the axis 'outside', 'inside' or 'cross',
                markSize: 95,                  // 
                showGridline: false, // wether to draw a gridline (across the whole grid) at this tick,
                show: true,         // wether to show the tick (mark and label),
                showLabel: true,    // wether to show the text label at the tick,
                formatString: '%d'   // format string to use with the axis tick formatter
            },
            showTicks: true,        // wether or not to show the tick labels,
            showTickMarks: true    // wether or not to show the tick marks
        },

        axes: {
            yaxis: {
                renderer: $.jqplot.CategoryAxisRenderer
            },
            xaxis: {
                 renderer: $.jqplot.LinearAxisRenderer,
                tickOptions: {
                    mark: 'cross', 
                    markSize: 2
                }
            }
        }
    });

推荐答案

xaxis设置中添加tickinterval属性.

xaxis: {
             renderer: $.jqplot.LinearAxisRenderer,
            tickOptions: {
                mark: 'cross', 
                markSize: 2,   
            },
            tickInterval: 1 //ADD THIS
        }

jqplot文档:

tickInterval -刻度之间的单位数.与numberTicks互斥.

tickInterval - number of units between ticks. Mutually exclusive with numberTicks.

这篇关于jq图-获取线性x轴刻度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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