【问题标题】:jq plot - getting linear x axis ticksjq plot - 获取线性 x 轴刻度
【发布时间】:2012-03-19 05:41:15
【问题描述】:

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

我使用 LinearAxisRenderer 作为 x 轴。

但是 x 轴的值是 0 ,1,1,2,2 等。

有没有办法将值设为 0、1、2、3 等。

提前致谢。

代码:

 $.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
                }
            }
        }
    });

【问题讨论】:

    标签: jqgrid jqplot


    【解决方案1】:

    tickinterval 属性添加到您的xaxis 设置中。

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

    来自jqplot documentation

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

    【讨论】:

      【解决方案2】:

      不要忘记添加“最大”和“最小”属性。如果您正在单独操作 xaxis 刻度。我已经为此浪费了很多时间。

      xaxis: {
                  renderer: $.jqplot.LinearAxisRenderer,
                  tickOptions: {
                      mark: 'cross', 
                      markSize: 2,   
                  },
                  tickInterval: 1 
                  max :0,
                  min :100
              }
      

      【讨论】:

        猜你喜欢
        • 2023-01-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-12-12
        • 2012-12-24
        • 1970-01-01
        • 2012-01-25
        • 2014-12-24
        相关资源
        最近更新 更多