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

Line chart: fixed the check dataColors options array for emptyness #47

Closed
wants to merge 2 commits into from

Conversation

ajduke
Copy link
Contributor

@ajduke ajduke commented Oct 13, 2019

Related issue

Fix #42

Due to options wasn't passed in Line object, it was getting options.dataColors as the [ ] empty due to which it wasn't getting any colors to plot

Screenshot before and after this change
I was using index.html charts example to test things out, so i had used the empty options for Line chart to replicate

before

image

after

image

@ajduke
Copy link
Contributor Author

ajduke commented Nov 9, 2019

@timqian Just wondering if you get chance to see this PR?

@@ -127,7 +130,7 @@ class Line {
.attr('class', 'xkcd-chart-line')
.attr('d', (d) => theLine(d.data))
.attr('fill', 'none')
.attr('stroke', (d, i) => (this.options.dataColors
.attr('stroke', (d, i) => (!isEmptyArray(this.options.dataColors)
Copy link
Owner

@timqian timqian Nov 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this.options is undefined, looks the error still exists as we are we are still trying to get a property of undefined here
this.options.dataColors.

May be check this.options && this.options.dataColors here?

Not 100 present sure as I dont get a computer nearby to play with the code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timqian Thanks for getting back.
Correct, let me do that check and update this PR

@timqian
Copy link
Owner

timqian commented Nov 9, 2019

@ajduke Thabks for the PR. And sorry for the late reply. I was doing some other stuff recently and haven't spent much time on this project recently. I will put more time on this repo after next week.

About this PR, after a quick look at the change. I failed to tell if this is the best way or not. I will review it again soon

@timqian
Copy link
Owner

timqian commented Nov 14, 2019

Using object.assign to define default values seems a better way: https://github.com/nfriedly/express-rate-limit/blob/master/lib/express-rate-limit.js#L5

@ajduke
Copy link
Contributor Author

ajduke commented Nov 21, 2019

Using object.assign to define default values seems a better way: https://github.com/nfriedly/express-rate-limit/blob/master/lib/express-rate-limit.js#L5

https://github.com/timqian/chart.xkcd/pull/47/files#diff-fbc43a77b4e8fe64398aa79145272a6bR151-R152

Is that comment for the above code? instead of function for checking empty array, use Object.assign. Is my understanding correct?

@timqian
Copy link
Owner

timqian commented Nov 22, 2019

Hi @ajduke
I fixed this issue on cef9ba2#diff-fbc43a77b4e8fe64398aa79145272a6bR33

By using Object Spread( the Object.assign in es6).

@ajduke ajduke closed this Dec 15, 2020
@ajduke ajduke deleted the master branch December 15, 2020 18:30
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

Successfully merging this pull request may close these issues.

options config required to plot the Line chart
2 participants