Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jqPlot custom tick labels

I've got data with X values from 0 to 55. I would like to see these values as a custom text in tick labels. Ideally, I want to specify some callback, like

function tickLabel(tickValue) {
    return "This is " + tickValue;
}

Is it possible?

like image 387
HiveHicks Avatar asked Feb 13 '12 15:02

HiveHicks


2 Answers

I've found a solution.

xaxis: {
  tickRenderer: $.jqplot.AxisTickRenderer,
  tickOptions: {
    formatter: function(format, value) { return "This is " + value; } 
  }
}
like image 189
HiveHicks Avatar answered Nov 16 '22 15:11

HiveHicks


Use something like:

var line1 = [['This is '.$value, $value], ...]

And call your plot as:

var plot1 = $.jqplot('chart1', [line1], {
    title: 'Title of your plot',
    series:[{renderer:$.jqplot.BarRenderer}],
    axesDefaults: {
        tickRenderer: $.jqplot.CanvasAxisTickRenderer ,
        tickOptions: {
          angle: -30,
          fontSize: '10pt'
        }
    },
    axes: {
      xaxis: {
        renderer: $.jqplot.CategoryAxisRenderer
      }
    }
  });
like image 2
groovekiller Avatar answered Nov 16 '22 15:11

groovekiller