views:

24

answers:

2

Hello all' I am new to Flot. I want to show weekly visitors statistics in my projects. I have to sho the visitors of the month but weekly on Flot. e.g. 1st week 1-5 there are 500 visitors. 6-12 there are 900 visitors. and so on. And I want to show X coordinates as 1-5,6-12,13-19,.... Can anyone suggest what to do. Strictly use Flot.

A: 

Check out the tickFormatter:

Alternatively, for ultimate control over how ticks look like you can provide a function to "tickFormatter". The function is passed two parameters, the tick value and an "axis" object with information, and should return a string.

So what you're looking for is something like this:

$.plot(placeholder, data, {
  //your options here
  xaxis: {
    tickFormatter: function(val,axis){
      return (val+1).toString()+'-'+(val+5).toString();
    }

  }

});
Ryley
A: 

I think you just want a plain old bar graph but are getting misled by the fact that you have some date-related data.

In the data you give Flot to graph, use fake numbers as x values that are just increasing integers. So for 1-5 put 0, for 6-12 put 1, and so on.

Then as Ryley says, use the tick formatter to put the labels on the x axis that you want.

See this as an example.

pfctdayelise