Quartz / Chartbuilder

A front-end charting application that facilitates easy creation of simple beautiful charts
http://quartz.github.io/Chartbuilder
MIT License
2.1k stars 354 forks source link

Allow support for parsing timestamps in date column #186

Closed ghost closed 9 years ago

ghost commented 9 years ago

Chartbuilder 2.0 is awesome. Thanks.

Is there a way to make the sugar parser look for "Timestamp" as well as "Date"?

I looked around and it isn't specified anywhere in your code. I assume is some auto Sugar.js function?

nsonnad commented 9 years ago

Sorry had to delete my incorrect comment. Was thinking "hey we should refactor this" but turns out, we already had. There is a parse-utils object that has what you're looking for. You can modify the datePattern defined at the top.

https://github.com/Quartz/Chartbuilder/blob/master/src/js/util/parse-utils.js

FYI: It gets called by the input parser and there are also a few tests for it.

ghost commented 9 years ago

Great. I'll check it out - and show what I did here. Bloomberg terminals love timestamps and not dates.

nsonnad commented 9 years ago

I may have misunderstood your question. Are you trying to get it to recognize the text timestamp or recognize timestamps as dates? I guess it would be both, now that I think about it. Sugar should be able to parse your timestamps just fine, see the docs. You will have to make sure to convert it to a number first, though.

ghost commented 9 years ago

Sorry, yes. I wanted it to recognise a column named "Timestamp". It already recognises data that is of the usual timestamps we use here.

yanofsky commented 9 years ago

If I understand properly, you'll want to change this line https://github.com/Quartz/Chartbuilder/blob/master/src/js/util/parse-utils.js#L2

var datePattern = /^(date|time|year)$/i;

to

var datePattern = /^(date|time|year|timestamp)$/i;
ghost commented 9 years ago

Works a treat. Thanks.