-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Fix targets ordering when containing numerical value as name #2314
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
Conversation
c19eafc to
18c3a1e
Compare
Codecov Report
@@ Coverage Diff @@
## master #2314 +/- ##
==========================================
- Coverage 76.85% 75.21% -1.65%
==========================================
Files 51 51
Lines 4126 4236 +110
==========================================
+ Hits 3171 3186 +15
- Misses 955 1050 +95
Continue to review full report at Codecov.
|
f9c3c31 to
380d88e
Compare
| return { keys, rows: newRows }; | ||
| }; | ||
|
|
||
| c3_chart_internal_fn.convertDataToTargets = function (data, appendXs) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now the shape of data is changed to { keys, rows }. I think we should document that in jsdoc format like:
/**
* Converts the data format into the target format.
* @param {Array} data.keys ...describe...
* @param {Array} data.rows ...describe...
* @param {boolean} appendXs
*/
spec/data.convert.js
Outdated
|
|
||
| // FIXME: how to have a proper testing environment? | ||
| const $$ = c3.chart.internal.fn; | ||
| $$.d3 = window.d3 ? window.d3 : typeof require !== 'undefined' ? require("d3") : undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think require("d3") must be available in testing environment and this can be $$.d3 = require("d3")
…nvert methods. This fixes the issue where targets order would not be kept when some of them have numerical values (ex: "1", "2", ..).
380d88e to
9f0e23f
Compare
|
@kt3k Thanks for the review, I updated the PR accordingly. edit: Not sure why codecov says the coverage will decrease that much in all those files though. |
|
I confirmed the data order preseved in this example with this change: var chart = c3.generate({
data: {
columns: [
['data5', 30],
['data1', 130],
['2', 35],
['data4', 60],
['data3', 100]
],
type: 'bar'
}
});Thanks for the contribution! |
This PR aim to fix issue where
data.order: nullwould still not leave the data order untouched if targets have numerical values.The idea of this update is to keep the ordered keys as an array in the pivot format returned by convert methods.