HumbleSoftware / Flotr2

Graphs and Charts for Canvas in JavaScript.
http://www.humblesoftware.com/flotr2/
MIT License
2.44k stars 526 forks source link

Allow X-Axis Values to be Strings? #192

Closed stinkycheeseman closed 11 years ago

stinkycheeseman commented 11 years ago

Hey-

I would get a lot of value out of the ability to plot with x-axis values being strings. Is there any plan on implementing this functionality?

Eg: [ [ "apples", 40], ["bananas": 23], ["carrots": 19] ]

cesutherland commented 11 years ago

Hello stinky cheese man-

what output are you trying to get?

-c

stinkycheeseman commented 11 years ago

I would like to get a chart whose x-axis is non-numeric like this: http://humblesoftware.com/flotr2/#!basic-timeline

Except I do not want to pass in a custom formatter. Ideally I could just pass in the string values I would like in the x-axis.

cesutherland commented 11 years ago

The ticks option ought to get you where you want to go:

http://jsfiddle.net/cesutherland/CYZ5s/

stinkycheeseman commented 11 years ago

Thanks CE,

This is exactly the effect I'd like, though I feel that passing in ["stinkycheeseman", 5] as a datapoint should also work. It doesn't feel natural to me to have to send in a placeholder numeric value only to override it in the "ticks" option.

Flotr.draw(container, [ [ ["stinky", 1], [ "cheese", 2], ["man", 3] ] ]);

should draw a chart where the x-axis contains string values. I think this is much cleaner and more intuitive than

Flotr.draw(container, [ [ [1, 1], [2, 1], [3, 1] ] ], { "ticks": [ [1, "stinky"], [2, "cheese"], [3, "man"] ] });

(for the record I don't want to seem really critical, I think this library is great and you've done a wonderful job with it)

cesutherland commented 11 years ago

No worries, thank you for the feedback! Much of the API (like this portion) was inherited from the original Flotr, so it'll stay as-is unfortunately. The graphing packages of the future will have much cleaner APIs to be certain.

stinkycheeseman commented 11 years ago

Cool- what's the expected timeframe for these packages of the future?

cesutherland commented 11 years ago

I was speaking more in general! I don't have or know a specific timeframe.

Marking this one resolved!