Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TimeSeries BarChart? #41

Open
chasers opened this issue Jan 12, 2021 · 4 comments
Open

TimeSeries BarChart? #41

chasers opened this issue Jan 12, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@chasers
Copy link

chasers commented Jan 12, 2021

It looks like there is not a way to use the TimeSeries scale with a bar chart?

I like to use time series bar charts for things a lot. Would love to be able to do this Contex. I can try to implement if you're up for it?

@mindok
Copy link
Owner

mindok commented Jan 12, 2021

Hi @chasers,
Yes - that's correct. Currently the bar chart is set up to use an "Ordinal Scale" only. This has a couple of special features to control plotting of bars - it has a get_band function that calculates the required width of a bar on the chart in plotting coordinates based on the required padding in plotting coordinates.

Ordinal Scale doesn't care about the data type, so you could easily create a dataset, sorted by date (and with pre-formatted date labels to make life easier) and feed that into the barchart. You would have to ensure regular time periods (e.g. daily) and create a row in the dataset for missing time periods with a zero value.

In terms of implementing a time series scale for a barchart, feel free. I'm happy to accept PRs. It may be worth getting your thoughts on use cases first and we could discuss possible approaches. There are a couple of potential approaches depending on what you are trying to achieve.

@chasers
Copy link
Author

chasers commented Jan 12, 2021

Thanks!

Yeah I've got it mostly there. This is now on our billing page:

Screen Shot 2021-01-12 at 3 44 18 PM

I tried unsuccessfully to overwrite the x-axis with my own. It's just the labels get a little noisy with more than 30 days
of data.

Can I simply customize the number of ticks in the x-axis? Like put a tick at every Nth column?

I'm evaluating this for more generalized simple dashboarding. So far I haven't run into any blockers really. LinePlot will be great!

@mindok
Copy link
Owner

mindok commented Jan 13, 2021

Hi @chasers, looks good!

No - there isn't an option to label every Nth for the ordinal scale as yet. It wouldn't be hard to do at all. Or we could set a max_category_labels or similar on the BarChart and pass it through to the scale and have the scale calculate how many to skip. That would be pretty quick & simple to do.

@srowley
Copy link
Contributor

srowley commented Feb 14, 2021

It occurs to me that a simple (if sort of indirect) way to support this would be to add separate classes to the x and y-axis ticks and labels, and then let the user set the stroke/fill to none (or whatever) with :nth-of-type selectors. That would have no impact on the API (or existing style sheets) with the added benefit of allowing some more granular styling generally.

@mindok mindok added the enhancement New feature or request label Jul 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants