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

Data does not support the Point structure #15

Closed
rodneyjoyce opened this issue Mar 15, 2018 · 7 comments
Closed

Data does not support the Point structure #15

rodneyjoyce opened this issue Mar 15, 2018 · 7 comments

Comments

@rodneyjoyce
Copy link

Hi,

I'm working on a graph that has 2 lines and a different number of point for each series.
If a List is used then the X-axis positions are ordinal, which means the graph is wrong - the JS version supports a Point.

For example:
Labels on X axis = 1,2,3,4,5
Data 1: x=3,y=20
Data 2: x=1,y=6, x=2,y=7,x=5,y=10

I'll have a look at the source to see if this could be supported easily..

@rodneyjoyce
Copy link
Author

Ah, I have found LineScatterDataset - looks like it does the job, thanks

@rodneyjoyce
Copy link
Author

Unfortunately, LineScatterData only works if the X axis is a number.

I am using different data - e.g. TimeStamps. Here's an example of the problem with day's of the week. It works in JS but currently not possible to do:

var data = {
labels: ["M","T","W","TH","F"],
datasets: [{
label: "Stock A",
data: [{
x: 'T',
y: 20
}, {
x: "TH",
y: 10
}],
}, {
label: "Stock B",
data: [{
x: "M",
y: 3
}, {
x: "T",
y: 11
},
{
x: "W",
y: 4
}, {
x: "TH",
y: 19
}
, {
x: "F",
y: 21
}],
}
]
};

@rodneyjoyce rodneyjoyce reopened this Mar 15, 2018
@mattosaurus
Copy link
Owner

Hi @rodneyjoyce, do you have a link to the chart.js documentation for this? Am happy to update this but would be good to make sure I include all possible datatypes.

@rodneyjoyce
Copy link
Author

Hi @mattosaurus . On this link, http://www.chartjs.org/docs/latest/charts/line.html, scroll down to "Data Structure" and you'll see the other format:
The data property of a dataset for a line chart can be passed in two formats."

@mattosaurus
Copy link
Owner

I've updated the x and y properties of LineScatterData to be strings, if they parse as a double then the value will be output without quotes, if not then the original string be output. I'm not sure this is the best way to do it as I imagine that most values for these will be doubles so these will now need to be converted to strings but I can't think of a better solution. This has been published now, let me know if you have any better ideas.

@rodneyjoyce
Copy link
Author

Ok, I'll try it out now and let you know, thanks.

@rodneyjoyce
Copy link
Author

Works great, thanks

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

No branches or pull requests

2 participants