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

How am I supposed to use the Time object? #8

Closed
FBueckert opened this issue Dec 15, 2017 · 3 comments
Closed

How am I supposed to use the Time object? #8

FBueckert opened this issue Dec 15, 2017 · 3 comments
Assignees
Labels

Comments

@FBueckert
Copy link

I've successfully used this tool to create some charts. The problem I'm currently running into is that I want to scale my X axis to be more linear instead of the current series scale it's been using.

Checking the chart.js documentation, I found the article on Time. Attempting to replicate that in ChartJSCore, though, is proving to be a challenge. I've found the Time object, which looks like it's supposed to meet this need, but I'm having trouble seeing where in the object graph it's supposed to be slotted into.

The best I've managed is to create a Scale object with a type of time, but the Scale object doesn't have any other reference to time. Searching the codebase, I don't see any reference to Time I can use to insert it into the options. Scales just takes an IList of Scale. Is Time supposed to extend Scale?

An example on how to use this would be extremely helpful.

@mattosaurus
Copy link
Owner

Hi @FBueckert, looks like I created the Time object but didn't actually integrate it into the Scale object. My initial thinking is that I'll create a new CartesianTimeScale object which will inherit from Scale and include it in here, I'll then update Scales to accept an IList of Object rather than Scale so this can be set to Scale or one of its derived classes. This feels a bit dirty but I can't really think of another nicer way to do.

If you've got a better idea then let me know or go ahead and submit some changes. I'll probably get a chance to update this around the start of next week.

@mattosaurus mattosaurus self-assigned this Dec 15, 2017
@FBueckert
Copy link
Author

FBueckert commented Dec 15, 2017

Looking through the Chart.js documentation, I see what you're trying to do; use the categories as parent objects. Maybe create a CartesianScale object, inherit it from Scale, and the Time object can inherit from the CartesianScale? That would give the added advantage of future cartesian object implementations. An IList of Object has a code smell to it, I agree.

@mattosaurus
Copy link
Owner

Hi @FBueckert, I've made these changes and published version 1.2 to NuGet. Unfortunately I've had to resort to changing the Tick and Scale classes to objects to allow them to accept the different possible types. It's not possible to have a generic parent class that will accept all child classes (you can cast the children but then you lose all additional attributes), I feel there probably is a better way to do this though so feel free to send me an example or point me towards the relevant documentation if you know of it.

I've updated the test project with examples of using the new scales so hopefully these should give you what you need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants