Skip to content

Commit

Permalink
Merge pull request #157 from nzzdev/release-3.0.2
Browse files Browse the repository at this point in the history
Release 3.0.2
  • Loading branch information
benib authored Oct 17, 2019
2 parents 582ab5d + 4b24260 commit 69921b5
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 18 deletions.
13 changes: 7 additions & 6 deletions chartTypes/bar-stacked/mapping.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const objectPath = require("object-path");
const array2d = require("array2d");
const Decimal = require("decimal.js");
const clone = require("clone");
const dataHelpers = require("../../helpers/data.js");

Expand Down Expand Up @@ -147,16 +147,17 @@ module.exports = function getMapping() {
path: "item.data",
mapToSpec: function(itemData, spec) {
// check if all rows sum up to 100
// use decimal.js to avoid floating point precision errors
const stackedSums = itemData
.slice(1)
.map(row => {
return row.slice(1).reduce((sum, cell) => {
return sum + cell;
}, 0);
return sum.plus(new Decimal(cell));
}, new Decimal(0));
})
.reduce((uniqueSums, sum) => {
if (!uniqueSums.includes(sum)) {
uniqueSums.push(sum);
if (!uniqueSums.includes(sum.toNumber())) {
uniqueSums.push(sum.toNumber());
}
return uniqueSums;
}, []);
Expand All @@ -167,7 +168,7 @@ module.exports = function getMapping() {
}

// set the ticks to 0/25/50/75/100
objectPath.set(spec, "axes.0.tickCount", undefined);
objectPath.set(spec, "axes.0.tickCount", 5);
objectPath.set(spec, "axes.0.values", [0, 25, 50, 75, 100]);
}
},
Expand Down
3 changes: 1 addition & 2 deletions chartTypes/bar-stacked/vega-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,7 @@
"labels": true,
"ticks": true,
"tickCount": 4,
"labelSeparation": 4,
"format": "~r"
"labelSeparation": 4
},
{
"orient": "left",
Expand Down
3 changes: 1 addition & 2 deletions chartTypes/bar/vega-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,7 @@
"grid": true,
"ticks": true,
"tickCount": 4,
"labelSeparation": 4,
"format": "~r"
"labelSeparation": 4
},
{
"orient": "left",
Expand Down
3 changes: 1 addition & 2 deletions chartTypes/column-stacked/vega-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,7 @@
"labels": true,
"grid": true,
"tickCount": 4,
"labelPadding": 2,
"format": "~r"
"labelPadding": 2
}
],
"autosize": {
Expand Down
3 changes: 1 addition & 2 deletions chartTypes/column/vega-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,7 @@
"grid": true,
"labels": true,
"tickCount": 4,
"labelPadding": 2,
"format": "~r"
"labelPadding": 2
}
],
"autosize": {
Expand Down
3 changes: 1 addition & 2 deletions chartTypes/line/vega-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@
"grid": true,
"labels": true,
"tickCount": 4,
"labelPadding": 2,
"format": "~r"
"labelPadding": 2
}
],
"marks": [
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "q-chart",
"version": "3.0.1",
"version": "3.0.2",
"description": "",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 69921b5

Please sign in to comment.