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

Scatter Dataset ShowLine forced False #36

Closed
elatoskinas opened this issue Jun 1, 2019 · 5 comments
Closed

Scatter Dataset ShowLine forced False #36

elatoskinas opened this issue Jun 1, 2019 · 5 comments
Assignees

Comments

@elatoskinas
Copy link

In Chart.js, sometimes it is more convenient to simply pass x & y values (instead of configuring string-based labels), and enable the show lines option to use a Scatter Chart as a Line Chart. In fact, this approach has been typically recommended in Stack Overflow posts, such as this one.

However, Charba forces ShowLine to be false for ScatterDataSet.

Was this intended, or was this simply a temporary placeholder?

@stockiNail stockiNail self-assigned this Jun 1, 2019
@stockiNail stockiNail added bug and removed bug labels Jun 1, 2019
@stockiNail
Copy link
Contributor

stockiNail commented Jun 3, 2019

@lightingft I checked the post and the sample written teher is already available by Charba.
In a Line chart you can use DataPoint (not only for timeseries). See here.
Here a sample:

LineDataset dataset1 = chart.newDataset();
dataset1.setLabel("dataset 1");

IsColor color1 = Colors.ALL[0];

dataset1.setBackgroundColor(color1.toHex());
dataset1.setBorderColor(color1.toHex());
dataset1.setFill(false);
double[] values = getRandomDigits(months);

DataPoint[] dp = new DataPoint[months];
for (int i=0; i<months; i++) {
	dp[i] = new DataPoint();
	dp[i].setX(i);
	dp[i].setY(values[i]);
}
dataset1.setDataPoints(dp);

Here the result:

linedp

About the showLine, it has been set to false because the scatter charts usually don't draw the line among points.
But, being Line chart equals to a Scatter one, you can use Line chart when needed.

What do you think?

@elatoskinas
Copy link
Author

@stockiNail Thanks for the response. I indeed followed a similar method that you showed for creating a Line Chart, and it worked nicely.

However, it still seemed rather odd to me that no matter what value is passed into the Scatter Data Set show line method, the value is forced to false, causing confusion at first as to why the method does not work when first using it.

Also, I think there are certain types of graphs that can be made with the Scatter Chart, but not with the Line Chart, where the point connection does not exactly follow the typical continuous Line Chart format. Here is an example posted in a Stack Overflow question.

@stockiNail
Copy link
Contributor

@lightingft yeah! I'll remove the overrided method in order that you can set the value that you want.

By default, it will be set to false. make sense?

@elatoskinas
Copy link
Author

@lightingft yeah! I'll remove the overrided method in order that you can set the value that you want.

By default, it will be set to false. make sense?

Excellent! That is a nice change indeed.

@stockiNail
Copy link
Contributor

Commited into master

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