Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@panthony
Copy link
Contributor

@panthony panthony commented Mar 22, 2018

This PR aim to fix issue where data.order: null would 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.

@panthony panthony force-pushed the fix/keep-targets-ordering branch from c19eafc to 18c3a1e Compare March 22, 2018 08:16
@codecov-io
Copy link

codecov-io commented Mar 22, 2018

Codecov Report

Merging #2314 into master will decrease coverage by 1.64%.
The diff coverage is 100%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
src/data.convert.js 87.05% <100%> (+7.63%) ⬆️
src/zoom.js 47.91% <0%> (-41.22%) ⬇️
src/interaction.js 39.2% <0%> (-10.8%) ⬇️
src/data.js 70.07% <0%> (-9.35%) ⬇️
src/shape.js 76.78% <0%> (-1.91%) ⬇️
src/api.tooltip.js 15% <0%> (-1.67%) ⬇️
src/axis.js 95.8% <0%> (-0.16%) ⬇️
src/shape.line.js 70.69% <0%> (-0.14%) ⬇️
src/drag.js 5.66% <0%> (-0.11%) ⬇️
src/api.flow.js 1.27% <0%> (-0.03%) ⬇️
... and 13 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5c30aed...9f0e23f. Read the comment docs.

@panthony panthony changed the title Pivot data format keep keys as separate property Fix targets ordering when containing numerical value as name Mar 22, 2018
@panthony panthony force-pushed the fix/keep-targets-ordering branch 3 times, most recently from f9c3c31 to 380d88e Compare March 30, 2018 06:26
@kt3k kt3k added this to the 0.6 milestone Apr 3, 2018
return { keys, rows: newRows };
};

c3_chart_internal_fn.convertDataToTargets = function (data, appendXs) {
Copy link
Member

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
 */


// FIXME: how to have a proper testing environment?
const $$ = c3.chart.internal.fn;
$$.d3 = window.d3 ? window.d3 : typeof require !== 'undefined' ? require("d3") : undefined;
Copy link
Member

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", ..).
@panthony panthony force-pushed the fix/keep-targets-ordering branch from 380d88e to 9f0e23f Compare April 10, 2018 06:16
@panthony
Copy link
Contributor Author

panthony commented Apr 10, 2018

@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.

@kt3k
Copy link
Member

kt3k commented Apr 12, 2018

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!

@kt3k kt3k merged commit d867f45 into c3js:master Apr 12, 2018
@panthony panthony deleted the fix/keep-targets-ordering branch August 7, 2019 14:35
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.

convertColumnsData do not preserve order when a category is '0' Wrong stack order when names a mix of text only and numbers only

3 participants