最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - jqPlot custom tick labels - Stack Overflow

programmeradmin1浏览0评论

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?

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?

Share Improve this question asked Feb 13, 2012 at 15:54 HiveHicksHiveHicks 2,3345 gold badges29 silver badges42 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 17

I've found a solution.

xaxis: {
  tickRenderer: $.jqplot.AxisTickRenderer,
  tickOptions: {
    formatter: function(format, value) { return "This is " + value; } 
  }
}

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
      }
    }
  });
发布评论

评论列表(0)

  1. 暂无评论