Skip to content

Commit 883b1fb

Browse files
3.4.0
1 parent a39a392 commit 883b1fb

12 files changed

+212
-17
lines changed

dist/external_d3_c3/keen-dataviz.js

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19548,7 +19548,7 @@ exports.default = function (d, defaultTitleFormat, defaultValueFormat, color) {
1954819548
var name = nameFormat(d[i].name);
1954919549
var value = valueFormat(d[i].value, d[i].ratio, d[i].id, d[i].index);
1955019550
var bgcolor = this.levelColor ? this.levelColor(d[i].value) : color(d[i].id);
19551-
if (value) {
19551+
if (value && !isNaN(value)) {
1955219552
text += "<tr class='" + this.CLASS.tooltipName + "-" + d[i].id + "'>";
1955319553
if (name.indexOf('__tooltip_ignore_name_field__') === -1) {
1955419554
text += "<td class='name'><span style='background-color:" + bgcolor + "'></span>" + (0, _escapeHtml.escapeHtml)(name) + "</td>";
@@ -20044,6 +20044,26 @@ function defineC3() {
2004420044

2004520045
var options = getDefaultOptions.call(this);
2004620046

20047+
// 100% for charts
20048+
var sumArray = calculateSumForPercents(this.dataset.matrix);
20049+
var oldMatrix = [];
20050+
if (options.stacking === 'percent' && (type === 'bar' || type === 'horizontal-bar' || type === 'area' || type === 'area-step' || type === 'area-spline')) {
20051+
oldMatrix = this.dataset.matrix;
20052+
this.dataset.matrix = [this.dataset.matrix[0]].concat(_toConsumableArray(calculatePercents(this.dataset.matrix, sumArray)));
20053+
options.axis = {
20054+
y: {
20055+
padding: {
20056+
top: 0
20057+
},
20058+
tick: {
20059+
format: function format(d) {
20060+
return d + '%';
20061+
}
20062+
}
20063+
}
20064+
};
20065+
}
20066+
2004720067
if (!!this.config.clearOnRender && options.data.columns.length > 0) {
2004820068
options.data.columns.splice(1);
2004920069
}
@@ -20140,6 +20160,7 @@ function defineC3() {
2014020160
}
2014120161

2014220162
if (!(options.tooltip && options.tooltip.show === false) && (options.legend.show === true || options.legend && options.legend.tooltip && options.legend.tooltip.show)) {
20163+
2014320164
// Apply custom tooltip
2014420165
options.tooltip = {
2014520166
contents: _tooltipContents2.default,
@@ -20149,6 +20170,16 @@ function defineC3() {
2014920170
var valueFormatted = c3CustomTooltipFiltering.call(_this, _value, ratio, id, index);
2015020171
if (_this.config.tooltip && _this.config.tooltip.format && _this.config.tooltip.format.value) {
2015120172
valueFormatted = _this.config.tooltip.format.value.call(_this, valueFormatted, ratio, id, index);
20173+
// Restore value from percents calculation for stacking 100% charts
20174+
if (options.stacking === 'percent' && (type === 'bar' || type === 'horizontal-bar' || type === 'area' || type === 'area-step' || type === 'area-spline')) {
20175+
valueFormatted = parseFloat((valueFormatted / 100 * sumArray[index]).toFixed(2));
20176+
}
20177+
return valueFormatted;
20178+
}
20179+
// Restore value from percents calculation for stacking 100% charts
20180+
if (options.stacking === 'percent' && (type === 'bar' || type === 'horizontal-bar' || type === 'area' || type === 'area-step' || type === 'area-spline')) {
20181+
valueFormatted = (valueFormatted / 100 * sumArray[index]).toFixed(2);
20182+
return parseFloat(valueFormatted);
2015220183
}
2015320184
return valueFormatted;
2015420185
}
@@ -20250,6 +20281,35 @@ function bindResizeListener(fn) {
2025020281
}
2025120282
}
2025220283

20284+
function calculateSumForPercents(matrix) {
20285+
var sumArray = [];
20286+
matrix.slice(1).forEach(function (d, i) {
20287+
d.forEach(function (e) {
20288+
if (typeof e === 'number') {
20289+
if (!sumArray[i]) {
20290+
sumArray[i] = e;
20291+
return sumArray[i];
20292+
}
20293+
sumArray[i] += e;
20294+
}
20295+
return sumArray[i];
20296+
});
20297+
});
20298+
return sumArray;
20299+
}
20300+
20301+
function calculatePercents(matrix, sumArray) {
20302+
var newValues = matrix.slice(1).map(function (d, i) {
20303+
return d.map(function (e) {
20304+
if (typeof e === 'number') {
20305+
return e / sumArray[i] * 100;
20306+
}
20307+
return e;
20308+
});
20309+
});
20310+
return newValues;
20311+
}
20312+
2025320313
/***/ }),
2025420314
/* 155 */
2025520315
/***/ (function(module, exports, __webpack_require__) {
@@ -20489,7 +20549,7 @@ function getDefaultType(parser) {
2048920549
/* 156 */
2049020550
/***/ (function(module) {
2049120551

20492-
module.exports = {"name":"keen-dataviz","description":"Data Visualization SDK for Keen IO","license":"MIT","version":"3.3.2","main":"dist/external_d3_c3/node/keen-dataviz.js","browser":"dist/external_d3_c3/keen-dataviz.js","style":"dist/keen-dataviz.css","scripts":{"start":"concurrently --kill-others \"NODE_ENV=development webpack-dev-server\" \"npm run postcss-watch\"","postcss-watch":"node_modules/postcss-cli/bin/postcss lib/style/keen-dataviz-c3.css -o test/demo/keen-dataviz.css --watch --config postcss.config.js","build":"NODE_ENV=production webpack -p && npm run build:css && NODE_ENV=production OPTIMIZE_MINIMIZE=1 webpack -p && npm run build:css && npm run build:css:min && npm run build:external_d3_c3 && npm run build:external_d3_c3:css && npm run build:external_d3_c3:css:min && npm run build:node","build:css":"node_modules/postcss-cli/bin/postcss lib/style/keen-dataviz-c3.css -o dist/keen-dataviz.css --config postcss.config.js","build:css:min":"OPTIMIZE_MINIMIZE=1 node_modules/postcss-cli/bin/postcss lib/style/keen-dataviz-c3.css -o dist/keen-dataviz.min.css --config postcss.config.js","build:external_d3_c3:css":"node_modules/postcss-cli/bin/postcss lib/style/keen-dataviz.css -o dist/external_d3_c3/keen-dataviz.css --config postcss.config.js","build:external_d3_c3:css:min":"OPTIMIZE_MINIMIZE=1 node_modules/postcss-cli/bin/postcss lib/style/keen-dataviz.css -o dist/external_d3_c3/keen-dataviz.min.css --config postcss.config.js","build:external_d3_c3":"NODE_ENV=production EXTERNAL_D3_C3=1 webpack -p && NODE_ENV=production EXTERNAL_D3_C3=1 OPTIMIZE_MINIMIZE=1 webpack -p","build:node":"TARGET=node NODE_ENV=production EXTERNAL_D3_C3=1 webpack -p","profile":"webpack --profile --json > stats.json","analyze":"webpack-bundle-analyzer stats.json /dist","version":"npm run build && git add .","postversion":"git push && git push --tags","test":"NODE_ENV=test jest","test:watch":"NODE_ENV=test jest --watch"},"repository":{"type":"git","url":"https://github.com/keen/keen-dataviz.js.git"},"bugs":"https://github.com/keen/keen-dataviz.js/issues","author":"Keen.IO <[email protected]> (https://keen.io/)","contributors":["Dustin Larimer <[email protected]> (https://github.com/dustinlarimer)","Joanne Cheng <[email protected]> (https://github.com/joannecheng)","Eric Anderson <[email protected]> (https://github.com/aroc)","Joe Wegner <[email protected]> (https://github.com/josephwegner)","Sara Falkoff <[email protected] (https://github.com/sfalkoff)","Adam Kasprowicz <[email protected]> (https://github.com/adamkasprowicz)","Dariusz Łacheta <[email protected]> (https://github.com/dariuszlacheta)"],"homepage":"https://keen.io","keywords":["d3","c3","Analytics","Stats","Statistics","Visualization","Visualizations","Data Visualization","Chart","Charts","Charting","Svg","Dataviz","Plots","Graphs","Funnels"],"dependencies":{"c3":"^0.6.12","d3":"^5.4.0","moment-timezone":"^0.5.21","promise-polyfill":"^8.0.0"},"devDependencies":{"autoprefixer":"^8.2.0","babel-loader":"^7.1.4","babel-plugin-transform-es2015-modules-commonjs":"^6.26.2","babel-plugin-transform-object-rest-spread":"^6.26.0","babel-preset-env":"^1.7.0","concurrently":"^3.5.1","cssnano":"^3.10.0","eslint":"^4.19.1","eslint-config-airbnb":"^16.1.0","eslint-loader":"^2.0.0","eslint-plugin-import":"^2.11.0","eslint-plugin-jsx-a11y":"^6.0.3","eslint-plugin-react":"^7.7.0","html-loader":"^0.5.5","html-webpack-plugin":"^3.2.0","jest":"^22.4.3","jest-environment-jsdom-c3":"^2.0.0","nock":"^9.2.6","postcss":"^6.0.21","postcss-cli":"^5.0.0","postcss-color-function":"^4.0.1","postcss-css-variables":"^0.8.1","postcss-cssnext":"^2.4.0","postcss-import":"^8.0.2","postcss-loader":"^2.1.3","precss":"^3.1.2","regenerator-runtime":"^0.11.1","replace-in-file":"^3.4.0","style-loader":"^0.20.3","webpack":"^4.5.0","webpack-bundle-analyzer":"^2.11.1","webpack-cli":"^2.0.13","webpack-dev-server":"^3.1.1","xhr-mock":"^2.3.2"}};
20552+
module.exports = {"name":"keen-dataviz","description":"Data Visualization SDK for Keen IO","license":"MIT","version":"3.4.0","main":"dist/external_d3_c3/node/keen-dataviz.js","browser":"dist/external_d3_c3/keen-dataviz.js","style":"dist/keen-dataviz.css","scripts":{"start":"concurrently --kill-others \"NODE_ENV=development webpack-dev-server\" \"npm run postcss-watch\"","postcss-watch":"node_modules/postcss-cli/bin/postcss lib/style/keen-dataviz-c3.css -o test/demo/keen-dataviz.css --watch --config postcss.config.js","build":"NODE_ENV=production webpack -p && npm run build:css && NODE_ENV=production OPTIMIZE_MINIMIZE=1 webpack -p && npm run build:css && npm run build:css:min && npm run build:external_d3_c3 && npm run build:external_d3_c3:css && npm run build:external_d3_c3:css:min && npm run build:node","build:css":"node_modules/postcss-cli/bin/postcss lib/style/keen-dataviz-c3.css -o dist/keen-dataviz.css --config postcss.config.js","build:css:min":"OPTIMIZE_MINIMIZE=1 node_modules/postcss-cli/bin/postcss lib/style/keen-dataviz-c3.css -o dist/keen-dataviz.min.css --config postcss.config.js","build:external_d3_c3:css":"node_modules/postcss-cli/bin/postcss lib/style/keen-dataviz.css -o dist/external_d3_c3/keen-dataviz.css --config postcss.config.js","build:external_d3_c3:css:min":"OPTIMIZE_MINIMIZE=1 node_modules/postcss-cli/bin/postcss lib/style/keen-dataviz.css -o dist/external_d3_c3/keen-dataviz.min.css --config postcss.config.js","build:external_d3_c3":"NODE_ENV=production EXTERNAL_D3_C3=1 webpack -p && NODE_ENV=production EXTERNAL_D3_C3=1 OPTIMIZE_MINIMIZE=1 webpack -p","build:node":"TARGET=node NODE_ENV=production EXTERNAL_D3_C3=1 webpack -p","profile":"webpack --profile --json > stats.json","analyze":"webpack-bundle-analyzer stats.json /dist","version":"npm run build && git add .","postversion":"git push && git push --tags","test":"NODE_ENV=test jest","test:watch":"NODE_ENV=test jest --watch"},"repository":{"type":"git","url":"https://github.com/keen/keen-dataviz.js.git"},"bugs":"https://github.com/keen/keen-dataviz.js/issues","author":"Keen.IO <[email protected]> (https://keen.io/)","contributors":["Dustin Larimer <[email protected]> (https://github.com/dustinlarimer)","Joanne Cheng <[email protected]> (https://github.com/joannecheng)","Eric Anderson <[email protected]> (https://github.com/aroc)","Joe Wegner <[email protected]> (https://github.com/josephwegner)","Sara Falkoff <[email protected] (https://github.com/sfalkoff)","Adam Kasprowicz <[email protected]> (https://github.com/adamkasprowicz)","Dariusz Łacheta <[email protected]> (https://github.com/dariuszlacheta)"],"homepage":"https://keen.io","keywords":["d3","c3","Analytics","Stats","Statistics","Visualization","Visualizations","Data Visualization","Chart","Charts","Charting","Svg","Dataviz","Plots","Graphs","Funnels"],"dependencies":{"c3":"^0.6.12","d3":"^5.4.0","moment-timezone":"^0.5.21","promise-polyfill":"^8.0.0"},"devDependencies":{"autoprefixer":"^8.2.0","babel-loader":"^7.1.4","babel-plugin-transform-es2015-modules-commonjs":"^6.26.2","babel-plugin-transform-object-rest-spread":"^6.26.0","babel-preset-env":"^1.7.0","concurrently":"^3.5.1","cssnano":"^3.10.0","eslint":"^4.19.1","eslint-config-airbnb":"^16.1.0","eslint-loader":"^2.0.0","eslint-plugin-import":"^2.11.0","eslint-plugin-jsx-a11y":"^6.0.3","eslint-plugin-react":"^7.7.0","html-loader":"^0.5.5","html-webpack-plugin":"^3.2.0","jest":"^22.4.3","jest-environment-jsdom-c3":"^2.0.0","nock":"^9.2.6","postcss":"^6.0.21","postcss-cli":"^5.0.0","postcss-color-function":"^4.0.1","postcss-css-variables":"^0.8.1","postcss-cssnext":"^2.4.0","postcss-import":"^8.0.2","postcss-loader":"^2.1.3","precss":"^3.1.2","regenerator-runtime":"^0.11.1","replace-in-file":"^3.4.0","style-loader":"^0.20.3","webpack":"^4.5.0","webpack-bundle-analyzer":"^2.11.1","webpack-cli":"^2.0.13","webpack-dev-server":"^3.1.1","xhr-mock":"^2.3.2"}};
2049320553

2049420554
/***/ }),
2049520555
/* 157 */
@@ -21338,6 +21398,11 @@ var Dataviz = exports.Dataviz = function Dataviz() {
2133821398
this.config.type = convertChartTypes(this.config.type);
2133921399
}
2134021400

21401+
// overwriting stacked when stacking added
21402+
if (this.config.stacking) {
21403+
this.config.stacked = true;
21404+
}
21405+
2134121406
// get DOM node by query
2134221407
if (this.config.container) {
2134321408
this.el(this.config.container);

dist/external_d3_c3/keen-dataviz.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/external_d3_c3/keen-dataviz.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/external_d3_c3/keen-dataviz.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)