Fleet with axis "String" x

When using the fleet, I would like to have a row based on the x axis. For example, I have a list of clients "Bob", "Chris", "Joe" and would like to build my income on the Y axis. (This is a histogram)

It seems that at first glance, the fleet only supports numeric types along the x axis. It's true?

+45
flot
Apr 28 2018-11-11T00:
source share
3 answers

@Matt is close, but it makes sense to just use the ticks parameter to directly indicate which marks should have labels:

 var options = { ... xaxis: { ticks: [[0,'Bob'],[1,'Chris'],[2,'Joe']] } ... }; 

EDIT : it looks like this (I added more data than labels, but you get the point).

+81
Apr 28 2018-11-11T00:
source share
— -

You should do this using the tickFormatter option in accordance with this question . I have not tried it myself, but I will do it:

 var xAxisLabels = ['Bob', 'Chris', 'Joe']; function xAxisLabelGenerator(x){ return xAxisLabels[x]; } var plot = $.plot($("#placeholder"), { // snip other options... xaxis: { transform: xAxisLabelGenerator, tickFormatter: xAxisLabelGenerator } }); 

This means that the actual x values ​​should be 0, 1, 2, ...

+15
Apr 28 '11 at 15:33
source share

The Categories plugin (jquery.flot.categories.js) will do this pretty nicely, so the data can be formatted as follows:

 var data = [ ["January", 10], ["February", 8], ["March", 4], ["April", 13], ["May", 17], ["June", 9] ]; 

and write it like this: enter image description here

See: http://www.flotcharts.org/flot/examples/categories/index.html

+15
Dec 19 '13 at 16:27
source share



All Articles