jq plot - получение линейных тиков по оси x - PullRequest
0 голосов
/ 19 марта 2012

У меня есть диаграмма jqPlot, которая отображается так, как показано на рисунке ниже.

Iam с использованием LinearAxisRenderer для оси x.

Но значения по оси x равны 0, 1, 1,2,2 и т. Д.

Есть ли способ получить значения 0, 1,2,3 и т. Д.

Заранее спасибо.

enter image description here

Код:

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

Ответы [ 2 ]

6 голосов
/ 19 марта 2012

Добавьте tickinterval свойство к вашим xaxis настройкам.

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

Из документации jqplot :

tickInterval - количество единиц между тиками. Взаимоисключающие с номерами.

0 голосов
/ 05 августа 2015

Не забудьте добавить свойства 'max' и 'min'.Если вы манипулируете галсами Xaxis индивидуально.Я потерял много времени на это.

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