billboard.js 3.4.1 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/dist/billboard.css +1 -1
- package/dist/billboard.js +3942 -1467
- package/dist/billboard.min.css +1 -1
- package/dist/billboard.min.js +2 -2
- package/dist/billboard.pkgd.js +8372 -5306
- package/dist/billboard.pkgd.min.js +3 -2
- package/dist/plugin/billboardjs-plugin-bubblecompare.js +29 -13
- package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-sparkline.js +375 -91
- package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-stanford.js +445 -108
- package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-tableview.js +339 -73
- package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-textoverlap.js +335 -74
- package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.js +4236 -3792
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.js +4637 -3889
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.js +4804 -3931
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.js +4595 -3865
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.js +4607 -3873
- package/dist/theme/datalab.css +1 -1
- package/dist/theme/datalab.min.css +1 -1
- package/dist/theme/graph.css +1 -1
- package/dist/theme/graph.min.css +1 -1
- package/dist/theme/insight.css +1 -1
- package/dist/theme/insight.min.css +1 -1
- package/dist-esm/billboard.js +837 -403
- package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +47 -75
- package/dist-esm/plugin/billboardjs-plugin-sparkline.js +68 -86
- package/dist-esm/plugin/billboardjs-plugin-stanford.js +52 -77
- package/dist-esm/plugin/billboardjs-plugin-tableview.js +49 -76
- package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +49 -76
- package/package.json +39 -39
- package/src/Chart/api/chart.ts +4 -1
- package/src/Chart/api/data.ts +2 -2
- package/src/Chart/api/flow.ts +125 -115
- package/src/ChartInternal/Axis/AxisRenderer.ts +29 -3
- package/src/ChartInternal/ChartInternal.ts +46 -18
- package/src/ChartInternal/data/IData.ts +2 -2
- package/src/ChartInternal/data/convert.helper.ts +226 -0
- package/src/ChartInternal/data/convert.ts +43 -210
- package/src/ChartInternal/data/load.ts +5 -4
- package/src/ChartInternal/interactions/zoom.ts +17 -4
- package/src/ChartInternal/internals/class.ts +1 -1
- package/src/ChartInternal/internals/color.ts +41 -42
- package/src/ChartInternal/internals/grid.ts +5 -3
- package/src/ChartInternal/internals/legend.ts +21 -6
- package/src/ChartInternal/internals/redraw.ts +5 -2
- package/src/ChartInternal/internals/scale.ts +3 -1
- package/src/ChartInternal/internals/size.axis.ts +5 -2
- package/src/ChartInternal/internals/style.ts +54 -0
- package/src/ChartInternal/internals/text.ts +118 -18
- package/src/ChartInternal/shape/arc.ts +4 -3
- package/src/ChartInternal/shape/area.ts +14 -7
- package/src/ChartInternal/shape/bar.ts +22 -12
- package/src/ChartInternal/shape/line.ts +3 -2
- package/src/ChartInternal/shape/point.ts +15 -9
- package/src/ChartInternal/shape/polar.ts +1 -1
- package/src/Plugin/sparkline/index.ts +22 -11
- package/src/Plugin/stanford/index.ts +10 -7
- package/src/Plugin/textoverlap/index.ts +4 -1
- package/src/config/Options/Options.ts +2 -0
- package/src/config/Options/common/boost.ts +31 -0
- package/src/config/Options/common/main.ts +15 -1
- package/src/config/Options/common/tooltip.ts +1 -1
- package/src/config/Options/data/data.ts +11 -3
- package/src/config/Options/shape/area.ts +6 -1
- package/src/config/Store/State.ts +3 -0
- package/src/module/browser.ts +2 -1
- package/src/module/generator.ts +18 -16
- package/src/module/util.ts +113 -0
- package/types/chart.d.ts +2 -2
- package/types/options.d.ts +45 -8
package/dist-esm/billboard.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* billboard.js, JavaScript chart library
|
|
6
6
|
* https://naver.github.io/billboard.js/
|
|
7
7
|
*
|
|
8
|
-
* @version 3.
|
|
8
|
+
* @version 3.5.0
|
|
9
9
|
*/
|
|
10
10
|
import { timeParse, utcParse, timeFormat, utcFormat } from 'd3-time-format';
|
|
11
11
|
import { pointer, select, namespaces, selectAll } from 'd3-selection';
|
|
@@ -33,7 +33,8 @@ var win = (function () {
|
|
|
33
33
|
/* eslint-enable no-new-func, no-undef */
|
|
34
34
|
// fallback for non-supported environments
|
|
35
35
|
win.requestIdleCallback = win.requestIdleCallback || (function (cb) { return setTimeout(cb, 1); });
|
|
36
|
-
win.cancelIdleCallback = win.cancelIdleCallback || (
|
|
36
|
+
// win.cancelIdleCallback = win.cancelIdleCallback || (id => clearTimeout(id));
|
|
37
|
+
win.requestAnimationFrame = win.requestAnimationFrame || (function (cb) { return setTimeout(cb, 1); });
|
|
37
38
|
var doc = win === null || win === void 0 ? void 0 : win.document;
|
|
38
39
|
|
|
39
40
|
/**
|
|
@@ -130,7 +131,7 @@ var TYPE_BY_CATEGORY = {
|
|
|
130
131
|
]
|
|
131
132
|
};
|
|
132
133
|
|
|
133
|
-
|
|
134
|
+
/******************************************************************************
|
|
134
135
|
Copyright (c) Microsoft Corporation.
|
|
135
136
|
|
|
136
137
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -525,6 +526,22 @@ function camelize(str, separator) {
|
|
|
525
526
|
* @private
|
|
526
527
|
*/
|
|
527
528
|
var toArray = function (v) { return [].slice.call(v); };
|
|
529
|
+
/**
|
|
530
|
+
* Add CSS rules
|
|
531
|
+
* @param {object} style Style object
|
|
532
|
+
* @param {string} selector Selector string
|
|
533
|
+
* @param {Array} prop Prps arrary
|
|
534
|
+
* @returns {number} Newely added rule index
|
|
535
|
+
* @private
|
|
536
|
+
*/
|
|
537
|
+
function addCssRules(style, selector, prop) {
|
|
538
|
+
var rootSelctor = style.rootSelctor, sheet = style.sheet;
|
|
539
|
+
var getSelector = function (s) { return s
|
|
540
|
+
.replace(/\s?(bb-)/g, ".$1")
|
|
541
|
+
.replace(/\.+/g, "."); };
|
|
542
|
+
var rule = "".concat(rootSelctor, " ").concat(getSelector(selector), " {").concat(prop.join(";"), "}");
|
|
543
|
+
return sheet[sheet.insertRule ? "insertRule" : "addRule"](rule, sheet.cssRules.length);
|
|
544
|
+
}
|
|
528
545
|
/**
|
|
529
546
|
* Get css rules for specified stylesheets
|
|
530
547
|
* @param {Array} styleSheets The stylesheets to get the rules from
|
|
@@ -808,6 +825,88 @@ function convertInputType(mouse, touch) {
|
|
|
808
825
|
// fallback to 'mouse' if no input type is detected.
|
|
809
826
|
return (hasMouse && "mouse") || (hasTouch && "touch") || "mouse";
|
|
810
827
|
}
|
|
828
|
+
/**
|
|
829
|
+
* Create and run on Web Worker
|
|
830
|
+
* @param {boolean} useWorker Use Web Worker
|
|
831
|
+
* @param {Function} fn Function to be executed in worker
|
|
832
|
+
* @param {Function} callback Callback function to receive result from worker
|
|
833
|
+
* @param {Array} depsFn Dependency functions to run given function(fn).
|
|
834
|
+
* @returns {object}
|
|
835
|
+
* @example
|
|
836
|
+
* const worker = runWorker(function(arg) {
|
|
837
|
+
* // do some tasks...
|
|
838
|
+
* console.log("param:", A(arg));
|
|
839
|
+
*
|
|
840
|
+
* return 1234;
|
|
841
|
+
* }, function(data) {
|
|
842
|
+
* // callback after worker is done
|
|
843
|
+
* console.log("result:", data);
|
|
844
|
+
* },
|
|
845
|
+
* [function A(){}]
|
|
846
|
+
* );
|
|
847
|
+
*
|
|
848
|
+
* worker(11111);
|
|
849
|
+
* @private
|
|
850
|
+
*/
|
|
851
|
+
function runWorker(useWorker, fn, callback, depsFn) {
|
|
852
|
+
var _a;
|
|
853
|
+
if (useWorker === void 0) { useWorker = true; }
|
|
854
|
+
var runFn;
|
|
855
|
+
if (win.Worker && useWorker) {
|
|
856
|
+
// Web Worker body
|
|
857
|
+
var blob = new Blob([
|
|
858
|
+
"".concat((_a = depsFn === null || depsFn === void 0 ? void 0 : depsFn.map(String).join(";")) !== null && _a !== void 0 ? _a : "", "\n\n\t\t\tself.onmessage=function({data}) {\n\t\t\t\tconst result = (").concat(fn.toString(), ").apply(null, data);\n\t\t\t\tself.postMessage(result);\n\t\t\t};")
|
|
859
|
+
], {
|
|
860
|
+
type: "text/javascript"
|
|
861
|
+
});
|
|
862
|
+
var worker_1 = new Worker(URL.createObjectURL(blob));
|
|
863
|
+
runFn = function () {
|
|
864
|
+
var args = [];
|
|
865
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
866
|
+
args[_i] = arguments[_i];
|
|
867
|
+
}
|
|
868
|
+
// trigger worker
|
|
869
|
+
worker_1.postMessage(args);
|
|
870
|
+
// listen worker
|
|
871
|
+
worker_1.onmessage = function (e) {
|
|
872
|
+
return callback(e.data);
|
|
873
|
+
};
|
|
874
|
+
// handle error
|
|
875
|
+
worker_1.onerror = function (e) {
|
|
876
|
+
console.error(e);
|
|
877
|
+
};
|
|
878
|
+
// return new Promise((resolve, reject) => {
|
|
879
|
+
// worker.onmessage = ({data}) => resolve(data);
|
|
880
|
+
// worker.onerror = reject;
|
|
881
|
+
// });
|
|
882
|
+
};
|
|
883
|
+
}
|
|
884
|
+
else {
|
|
885
|
+
runFn = function () {
|
|
886
|
+
var args = [];
|
|
887
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
888
|
+
args[_i] = arguments[_i];
|
|
889
|
+
}
|
|
890
|
+
var res = fn.apply(void 0, args);
|
|
891
|
+
callback(res);
|
|
892
|
+
};
|
|
893
|
+
}
|
|
894
|
+
return runFn;
|
|
895
|
+
}
|
|
896
|
+
/**
|
|
897
|
+
* Run function until given condition function return true
|
|
898
|
+
* @param {Function} fn Function to be executed when condition is true
|
|
899
|
+
* @param {Function} conditionFn Condition function to check if condition is true
|
|
900
|
+
* @private
|
|
901
|
+
*/
|
|
902
|
+
function runUntil(fn, conditionFn) {
|
|
903
|
+
if (conditionFn() === false) {
|
|
904
|
+
win.requestAnimationFrame(function () { return runUntil(fn, conditionFn); });
|
|
905
|
+
}
|
|
906
|
+
else {
|
|
907
|
+
fn();
|
|
908
|
+
}
|
|
909
|
+
}
|
|
811
910
|
|
|
812
911
|
/**
|
|
813
912
|
* Check chart type module imports.
|
|
@@ -1105,6 +1204,8 @@ var State = /** @class */ (function () {
|
|
|
1105
1204
|
xAxisHeight: 0,
|
|
1106
1205
|
hasAxis: false,
|
|
1107
1206
|
hasRadar: false,
|
|
1207
|
+
// for data CSS rule index (used when boost.useCssRule is true)
|
|
1208
|
+
cssRule: {},
|
|
1108
1209
|
current: {
|
|
1109
1210
|
// chart whole dimension
|
|
1110
1211
|
width: 0,
|
|
@@ -1369,12 +1470,26 @@ var main = {
|
|
|
1369
1470
|
* @type {object}
|
|
1370
1471
|
* @property {object} [resize] resize object
|
|
1371
1472
|
* @property {boolean} [resize.auto=true] Set chart resize automatically on viewport changes.
|
|
1473
|
+
* @property {boolean|number} [resize.timer=true] Set resize timer option.
|
|
1474
|
+
* - **NOTE:**
|
|
1475
|
+
* - The resize function will be called using: true - `setTimeout()`, false - `requestIdleCallback()`.
|
|
1476
|
+
* - Given number(delay in ms) value, resize function will be triggered using `setTimer()` with given delay.
|
|
1372
1477
|
* @example
|
|
1373
1478
|
* resize: {
|
|
1374
|
-
* auto: false
|
|
1479
|
+
* auto: false,
|
|
1480
|
+
*
|
|
1481
|
+
* // set resize function will be triggered using `setTimer()`
|
|
1482
|
+
* timer: true,
|
|
1483
|
+
*
|
|
1484
|
+
* // set resize function will be triggered using `requestIdleCallback()`
|
|
1485
|
+
* timer: false,
|
|
1486
|
+
*
|
|
1487
|
+
* // set resize function will be triggered using `setTimer()` with a delay of `100ms`.
|
|
1488
|
+
* timer: 100
|
|
1375
1489
|
* }
|
|
1376
1490
|
*/
|
|
1377
1491
|
resize_auto: true,
|
|
1492
|
+
resize_timer: true,
|
|
1378
1493
|
/**
|
|
1379
1494
|
* Set a callback to execute when the chart is clicked.
|
|
1380
1495
|
* @name onclick
|
|
@@ -1588,6 +1703,38 @@ var main = {
|
|
|
1588
1703
|
regions: []
|
|
1589
1704
|
};
|
|
1590
1705
|
|
|
1706
|
+
/**
|
|
1707
|
+
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
1708
|
+
* billboard.js project is licensed under the MIT license
|
|
1709
|
+
*/
|
|
1710
|
+
/**
|
|
1711
|
+
* boost config options
|
|
1712
|
+
*/
|
|
1713
|
+
var boost = {
|
|
1714
|
+
/**
|
|
1715
|
+
* Set boost options
|
|
1716
|
+
* @name boost
|
|
1717
|
+
* @memberof Options
|
|
1718
|
+
* @type {object}
|
|
1719
|
+
* @property {object} boost boost object
|
|
1720
|
+
* @property {boolean} [boost.useCssRule=false] Avoid setting inline styles for each shape elements.
|
|
1721
|
+
* - **NOTE:**
|
|
1722
|
+
* - Will append <style> to the head tag and will add shpes' CSS rules dynamically.
|
|
1723
|
+
* - For now, covers colors related properties (fill, stroke, etc.) only.
|
|
1724
|
+
* @property {boolean} [boost.useWorker=false] Use Web Worker as possible for processing.
|
|
1725
|
+
* - **NOTE:**
|
|
1726
|
+
* - For now, only applies for data conversion at the initial time.
|
|
1727
|
+
* - As of Web Worker's async nature, handling chart instance synchrously is not recommended.
|
|
1728
|
+
* @example
|
|
1729
|
+
* boost: {
|
|
1730
|
+
* useCssRule: true,
|
|
1731
|
+
* useWorker: false
|
|
1732
|
+
* }
|
|
1733
|
+
*/
|
|
1734
|
+
boost_useCssRule: false,
|
|
1735
|
+
boost_useWorker: false
|
|
1736
|
+
};
|
|
1737
|
+
|
|
1591
1738
|
/**
|
|
1592
1739
|
* data config options
|
|
1593
1740
|
*/
|
|
@@ -1627,6 +1774,7 @@ var data$2 = {
|
|
|
1627
1774
|
data_idConverter: function (id) { return id; },
|
|
1628
1775
|
/**
|
|
1629
1776
|
* Set custom data name.
|
|
1777
|
+
* If a name is set to `null`, the series is omitted from the legend.
|
|
1630
1778
|
* @name data․names
|
|
1631
1779
|
* @memberof Options
|
|
1632
1780
|
* @type {object}
|
|
@@ -1885,6 +2033,8 @@ var data$2 = {
|
|
|
1885
2033
|
* @property {object} [data.labels.position] Set each dataset position, relative the original.
|
|
1886
2034
|
* @property {number} [data.labels.position.x=0] x coordinate position, relative the original.
|
|
1887
2035
|
* @property {number} [data.labels.position.y=0] y coordinate position, relative the original.
|
|
2036
|
+
* @property {object} [data.labels.rotate] Rotate label text. Specify degree value in a range of `0 ~ 360`.
|
|
2037
|
+
* - **NOTE:** Depend on rotate value, text position need to be adjusted manually(using `data.labels.position` option) to be shown nicely.
|
|
1888
2038
|
* @memberof Options
|
|
1889
2039
|
* @type {object}
|
|
1890
2040
|
* @default {}
|
|
@@ -1894,6 +2044,7 @@ var data$2 = {
|
|
|
1894
2044
|
* @see [Demo: label multiline](https://naver.github.io/billboard.js/demo/#Data.DataLabelMultiline)
|
|
1895
2045
|
* @see [Demo: label overlap](https://naver.github.io/billboard.js/demo/#Data.DataLabelOverlap)
|
|
1896
2046
|
* @see [Demo: label position](https://naver.github.io/billboard.js/demo/#Data.DataLabelPosition)
|
|
2047
|
+
* @see [Demo: label rotate](https://naver.github.io/billboard.js/demo/#Data.DataLabelRotate)
|
|
1897
2048
|
* @example
|
|
1898
2049
|
* data: {
|
|
1899
2050
|
* labels: true,
|
|
@@ -1952,7 +2103,10 @@ var data$2 = {
|
|
|
1952
2103
|
* position: {
|
|
1953
2104
|
* data1: {x: 5, y: 5},
|
|
1954
2105
|
* data2: {x: 10, y: -20}
|
|
1955
|
-
* }
|
|
2106
|
+
* },
|
|
2107
|
+
*
|
|
2108
|
+
* // rotate degree for label text
|
|
2109
|
+
* rotate: 90
|
|
1956
2110
|
* }
|
|
1957
2111
|
* }
|
|
1958
2112
|
*/
|
|
@@ -2723,7 +2877,7 @@ var tooltip$2 = {
|
|
|
2723
2877
|
* - **Note:**
|
|
2724
2878
|
* - defaultTitleFormat:
|
|
2725
2879
|
* - if `axis.x.tick.format` option will be used if set.
|
|
2726
|
-
* - otherwise, will return
|
|
2880
|
+
* - otherwise, will return function based on tick format type(category, timeseries).
|
|
2727
2881
|
* - defaultValueFormat:
|
|
2728
2882
|
* - for Arc type (except gauge, radar), the function will return value from `(ratio * 100).toFixed(1)`.
|
|
2729
2883
|
* - for Axis based types, will be used `axis.[y|y2].tick.format` option value if is set.
|
|
@@ -2912,7 +3066,7 @@ var tooltip$2 = {
|
|
|
2912
3066
|
*/
|
|
2913
3067
|
var Options = /** @class */ (function () {
|
|
2914
3068
|
function Options() {
|
|
2915
|
-
return deepClone(main, data$2, color$1, interaction$1, legend$2, title$1, tooltip$2, Options.data);
|
|
3069
|
+
return deepClone(main, boost, data$2, color$1, interaction$1, legend$2, title$1, tooltip$2, Options.data);
|
|
2916
3070
|
}
|
|
2917
3071
|
Options.setOptions = function (options) {
|
|
2918
3072
|
this.data = options
|
|
@@ -3026,18 +3180,26 @@ var Cache = /** @class */ (function () {
|
|
|
3026
3180
|
var setTimeout$1 = win.setTimeout, clearTimeout$1 = win.clearTimeout;
|
|
3027
3181
|
/**
|
|
3028
3182
|
* Generate resize queue function
|
|
3183
|
+
* @param {boolean|number} option Resize option
|
|
3029
3184
|
* @returns {Fucntion}
|
|
3030
3185
|
* @private
|
|
3031
3186
|
*/
|
|
3032
|
-
function generateResize() {
|
|
3187
|
+
function generateResize(option) {
|
|
3033
3188
|
var fn = [];
|
|
3034
3189
|
var timeout;
|
|
3035
3190
|
var callResizeFn = function () {
|
|
3036
3191
|
// Delay all resize functions call, to prevent unintended excessive call from resize event
|
|
3037
3192
|
callResizeFn.clear();
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3193
|
+
if (option === false && win.requestIdleCallback) {
|
|
3194
|
+
requestIdleCallback(function () {
|
|
3195
|
+
fn.forEach(function (f) { return f(); });
|
|
3196
|
+
}, { timeout: 200 });
|
|
3197
|
+
}
|
|
3198
|
+
else {
|
|
3199
|
+
timeout = setTimeout$1(function () {
|
|
3200
|
+
fn.forEach(function (f) { return f(); });
|
|
3201
|
+
}, isNumber(option) ? option : 200);
|
|
3202
|
+
}
|
|
3041
3203
|
};
|
|
3042
3204
|
callResizeFn.clear = function () {
|
|
3043
3205
|
if (timeout) {
|
|
@@ -3058,9 +3220,9 @@ function generateWait() {
|
|
|
3058
3220
|
var transitionsToWait = [];
|
|
3059
3221
|
// 'f' is called as selection.call(f, ...);
|
|
3060
3222
|
var f = function (selection, callback) {
|
|
3061
|
-
var timer;
|
|
3062
3223
|
/**
|
|
3063
3224
|
* Check if transition is complete
|
|
3225
|
+
* @returns {boolean} Whether transition is complete
|
|
3064
3226
|
* @private
|
|
3065
3227
|
*/
|
|
3066
3228
|
function loop() {
|
|
@@ -3083,15 +3245,11 @@ function generateWait() {
|
|
|
3083
3245
|
done++;
|
|
3084
3246
|
}
|
|
3085
3247
|
}
|
|
3086
|
-
|
|
3087
|
-
if (done === transitionsToWait.length) {
|
|
3088
|
-
callback === null || callback === void 0 ? void 0 : callback();
|
|
3089
|
-
}
|
|
3090
|
-
else {
|
|
3091
|
-
timer = setTimeout$1(loop, 50);
|
|
3092
|
-
}
|
|
3248
|
+
return done === transitionsToWait.length;
|
|
3093
3249
|
}
|
|
3094
|
-
|
|
3250
|
+
runUntil(function () {
|
|
3251
|
+
callback === null || callback === void 0 ? void 0 : callback();
|
|
3252
|
+
}, loop);
|
|
3095
3253
|
};
|
|
3096
3254
|
f.add = function (t) {
|
|
3097
3255
|
isArray(t) ?
|
|
@@ -3105,6 +3263,197 @@ function generateWait() {
|
|
|
3105
3263
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
3106
3264
|
* billboard.js project is licensed under the MIT license
|
|
3107
3265
|
*/
|
|
3266
|
+
/***** Functions to be executed on Web Worker *****
|
|
3267
|
+
* NOTE: Don't allowed to use
|
|
3268
|
+
* - arrow function syntax
|
|
3269
|
+
* - Utils functions
|
|
3270
|
+
*/
|
|
3271
|
+
/**
|
|
3272
|
+
* Convert Columns data
|
|
3273
|
+
* @param {object} columns
|
|
3274
|
+
* @returns {Array}
|
|
3275
|
+
* @private
|
|
3276
|
+
*/
|
|
3277
|
+
function columns(columns) {
|
|
3278
|
+
var newRows = [];
|
|
3279
|
+
columns.forEach(function (col, i) {
|
|
3280
|
+
var key = col[0];
|
|
3281
|
+
col.forEach(function (v, j) {
|
|
3282
|
+
if (j > 0) {
|
|
3283
|
+
if (typeof newRows[j - 1] === "undefined") {
|
|
3284
|
+
newRows[j - 1] = {};
|
|
3285
|
+
}
|
|
3286
|
+
if (typeof v === "undefined") {
|
|
3287
|
+
throw new Error("Source data is missing a component at (".concat(i, ", ").concat(j, ")!"));
|
|
3288
|
+
}
|
|
3289
|
+
newRows[j - 1][key] = v;
|
|
3290
|
+
}
|
|
3291
|
+
});
|
|
3292
|
+
});
|
|
3293
|
+
return newRows;
|
|
3294
|
+
}
|
|
3295
|
+
/**
|
|
3296
|
+
* Convert Rows data
|
|
3297
|
+
* @param {object} columns
|
|
3298
|
+
* @returns {Array}
|
|
3299
|
+
* @private
|
|
3300
|
+
*/
|
|
3301
|
+
function rows(rows) {
|
|
3302
|
+
var keys = rows[0];
|
|
3303
|
+
var newRows = [];
|
|
3304
|
+
rows.forEach(function (row, i) {
|
|
3305
|
+
if (i > 0) {
|
|
3306
|
+
var newRow_1 = {};
|
|
3307
|
+
row.forEach(function (v, j) {
|
|
3308
|
+
if (typeof v === "undefined") {
|
|
3309
|
+
throw new Error("Source data is missing a component at (".concat(i, ", ").concat(j, ")!"));
|
|
3310
|
+
}
|
|
3311
|
+
newRow_1[keys[j]] = v;
|
|
3312
|
+
});
|
|
3313
|
+
newRows.push(newRow_1);
|
|
3314
|
+
}
|
|
3315
|
+
});
|
|
3316
|
+
return newRows;
|
|
3317
|
+
}
|
|
3318
|
+
/**
|
|
3319
|
+
* Convert JSON data
|
|
3320
|
+
* @param {object} columns
|
|
3321
|
+
* @returns {Array}
|
|
3322
|
+
* @private
|
|
3323
|
+
*/
|
|
3324
|
+
function json(json, keysParam) {
|
|
3325
|
+
var newRows = [];
|
|
3326
|
+
var findValueInJson = function (object, path) {
|
|
3327
|
+
if (object[path] !== undefined) {
|
|
3328
|
+
return object[path];
|
|
3329
|
+
}
|
|
3330
|
+
var convertedPath = path.replace(/\[(\w+)\]/g, ".$1"); // convert indexes to properties (replace [] with .)
|
|
3331
|
+
var pathArray = convertedPath.replace(/^\./, "").split("."); // strip a leading dot
|
|
3332
|
+
var target = object;
|
|
3333
|
+
pathArray.some(function (k) {
|
|
3334
|
+
return !(target = target && k in target ?
|
|
3335
|
+
target[k] : undefined);
|
|
3336
|
+
});
|
|
3337
|
+
return target;
|
|
3338
|
+
};
|
|
3339
|
+
var targetKeys;
|
|
3340
|
+
var data;
|
|
3341
|
+
if (Array.isArray(json)) {
|
|
3342
|
+
if (keysParam.x) {
|
|
3343
|
+
targetKeys = keysParam.value.concat(keysParam.x);
|
|
3344
|
+
}
|
|
3345
|
+
else {
|
|
3346
|
+
targetKeys = keysParam.value;
|
|
3347
|
+
}
|
|
3348
|
+
newRows.push(targetKeys);
|
|
3349
|
+
json.forEach(function (o) {
|
|
3350
|
+
var newRow = targetKeys.map(function (key) {
|
|
3351
|
+
// convert undefined to null because undefined data will be removed in convertDataToTargets()
|
|
3352
|
+
var v = findValueInJson(o, key);
|
|
3353
|
+
if (typeof v === "undefined") {
|
|
3354
|
+
v = null;
|
|
3355
|
+
}
|
|
3356
|
+
return v;
|
|
3357
|
+
});
|
|
3358
|
+
newRows.push(newRow);
|
|
3359
|
+
});
|
|
3360
|
+
data = rows(newRows);
|
|
3361
|
+
}
|
|
3362
|
+
else {
|
|
3363
|
+
Object.keys(json).forEach(function (key) {
|
|
3364
|
+
var tmp = json[key].concat();
|
|
3365
|
+
tmp.unshift(key);
|
|
3366
|
+
newRows.push(tmp);
|
|
3367
|
+
});
|
|
3368
|
+
data = columns(newRows);
|
|
3369
|
+
}
|
|
3370
|
+
return data;
|
|
3371
|
+
}
|
|
3372
|
+
/***** Functions can't be executed on Web Worker *****/
|
|
3373
|
+
/**
|
|
3374
|
+
* Convert URL data
|
|
3375
|
+
* @param {string} url Remote URL
|
|
3376
|
+
* @param {string} mimeType MIME type string: json | csv | tsv
|
|
3377
|
+
* @param {object} headers Header object
|
|
3378
|
+
* @param {object} keys Key object
|
|
3379
|
+
* @param {Function} done Callback function
|
|
3380
|
+
* @private
|
|
3381
|
+
*/
|
|
3382
|
+
function url(url, mimeType, headers, keys, done) {
|
|
3383
|
+
if (mimeType === void 0) { mimeType = "csv"; }
|
|
3384
|
+
var req = new XMLHttpRequest();
|
|
3385
|
+
var converter = { csv: csv, tsv: tsv, json: json };
|
|
3386
|
+
req.open("GET", url);
|
|
3387
|
+
if (headers) {
|
|
3388
|
+
Object.keys(headers).forEach(function (key) {
|
|
3389
|
+
req.setRequestHeader(key, headers[key]);
|
|
3390
|
+
});
|
|
3391
|
+
}
|
|
3392
|
+
req.onreadystatechange = function () {
|
|
3393
|
+
if (req.readyState === 4) {
|
|
3394
|
+
if (req.status === 200) {
|
|
3395
|
+
var response = req.responseText;
|
|
3396
|
+
response && done.call(this, converter[mimeType](mimeType === "json" ? JSON.parse(response) : response, keys));
|
|
3397
|
+
}
|
|
3398
|
+
else {
|
|
3399
|
+
throw new Error("".concat(url, ": Something went wrong loading!"));
|
|
3400
|
+
}
|
|
3401
|
+
}
|
|
3402
|
+
};
|
|
3403
|
+
req.send();
|
|
3404
|
+
}
|
|
3405
|
+
/**
|
|
3406
|
+
* Convert CSV/TSV data
|
|
3407
|
+
* @param {object} parser Parser object
|
|
3408
|
+
* @param {object} xsv Data
|
|
3409
|
+
* @returns {object}
|
|
3410
|
+
* @private
|
|
3411
|
+
*/
|
|
3412
|
+
function convertCsvTsvToData(parser, xsv) {
|
|
3413
|
+
var rows = parser.rows(xsv);
|
|
3414
|
+
var d;
|
|
3415
|
+
if (rows.length === 1) {
|
|
3416
|
+
d = [{}];
|
|
3417
|
+
rows[0].forEach(function (id) {
|
|
3418
|
+
d[0][id] = null;
|
|
3419
|
+
});
|
|
3420
|
+
}
|
|
3421
|
+
else {
|
|
3422
|
+
d = parser.parse(xsv);
|
|
3423
|
+
}
|
|
3424
|
+
return d;
|
|
3425
|
+
}
|
|
3426
|
+
function csv(xsv) {
|
|
3427
|
+
return convertCsvTsvToData({
|
|
3428
|
+
rows: csvParseRows,
|
|
3429
|
+
parse: csvParse
|
|
3430
|
+
}, xsv);
|
|
3431
|
+
}
|
|
3432
|
+
function tsv(tsv) {
|
|
3433
|
+
return convertCsvTsvToData({
|
|
3434
|
+
rows: tsvParseRows,
|
|
3435
|
+
parse: tsvParse
|
|
3436
|
+
}, tsv);
|
|
3437
|
+
}
|
|
3438
|
+
|
|
3439
|
+
/**
|
|
3440
|
+
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
3441
|
+
* billboard.js project is licensed under the MIT license
|
|
3442
|
+
*/
|
|
3443
|
+
/**
|
|
3444
|
+
* Get data key for JSON
|
|
3445
|
+
* @param {string|object} keysParam Key params
|
|
3446
|
+
* @param {object} config Config object
|
|
3447
|
+
* @returns {string} Data key
|
|
3448
|
+
* @private
|
|
3449
|
+
*/
|
|
3450
|
+
function getDataKeyForJson(keysParam, config) {
|
|
3451
|
+
var keys = keysParam || (config === null || config === void 0 ? void 0 : config.data_keys);
|
|
3452
|
+
if (keys === null || keys === void 0 ? void 0 : keys.x) {
|
|
3453
|
+
config.data_x = keys.x;
|
|
3454
|
+
}
|
|
3455
|
+
return keys;
|
|
3456
|
+
}
|
|
3108
3457
|
/**
|
|
3109
3458
|
* Data convert
|
|
3110
3459
|
* @memberof ChartInternal
|
|
@@ -3115,11 +3464,12 @@ var dataConvert = {
|
|
|
3115
3464
|
* Convert data according its type
|
|
3116
3465
|
* @param {object} args data object
|
|
3117
3466
|
* @param {Function} [callback] callback for url(XHR) type loading
|
|
3118
|
-
* @returns {object}
|
|
3119
3467
|
* @private
|
|
3120
3468
|
*/
|
|
3121
3469
|
convertData: function (args, callback) {
|
|
3122
|
-
var
|
|
3470
|
+
var config = this.config;
|
|
3471
|
+
var useWorker = config.boost_useWorker;
|
|
3472
|
+
var data = args;
|
|
3123
3473
|
if (args.bindto) {
|
|
3124
3474
|
data = {};
|
|
3125
3475
|
["url", "mimeType", "headers", "keys", "json", "keys", "rows", "columns"]
|
|
@@ -3130,175 +3480,21 @@ var dataConvert = {
|
|
|
3130
3480
|
}
|
|
3131
3481
|
});
|
|
3132
3482
|
}
|
|
3133
|
-
else {
|
|
3134
|
-
data = args;
|
|
3135
|
-
}
|
|
3136
3483
|
if (data.url && callback) {
|
|
3137
|
-
|
|
3484
|
+
url(data.url, data.mimeType, data.headers, getDataKeyForJson(data.keys, config), callback);
|
|
3138
3485
|
}
|
|
3139
3486
|
else if (data.json) {
|
|
3140
|
-
|
|
3487
|
+
runWorker(useWorker, json, callback, [columns, rows])(data.json, getDataKeyForJson(data.keys, config));
|
|
3141
3488
|
}
|
|
3142
3489
|
else if (data.rows) {
|
|
3143
|
-
|
|
3490
|
+
runWorker(useWorker, rows, callback)(data.rows);
|
|
3144
3491
|
}
|
|
3145
3492
|
else if (data.columns) {
|
|
3146
|
-
|
|
3493
|
+
runWorker(useWorker, columns, callback)(data.columns);
|
|
3147
3494
|
}
|
|
3148
3495
|
else if (args.bindto) {
|
|
3149
3496
|
throw Error("url or json or rows or columns is required.");
|
|
3150
3497
|
}
|
|
3151
|
-
return isArray(data) && data;
|
|
3152
|
-
},
|
|
3153
|
-
/**
|
|
3154
|
-
* Convert URL data
|
|
3155
|
-
* @param {string} url Remote URL
|
|
3156
|
-
* @param {string} mimeType MIME type string: json | csv | tsv
|
|
3157
|
-
* @param {object} headers Header object
|
|
3158
|
-
* @param {object} keys Key object
|
|
3159
|
-
* @param {Function} done Callback function
|
|
3160
|
-
* @private
|
|
3161
|
-
*/
|
|
3162
|
-
convertUrlToData: function (url, mimeType, headers, keys, done) {
|
|
3163
|
-
var _this = this;
|
|
3164
|
-
if (mimeType === void 0) { mimeType = "csv"; }
|
|
3165
|
-
var req = new XMLHttpRequest();
|
|
3166
|
-
req.open("GET", url);
|
|
3167
|
-
if (headers) {
|
|
3168
|
-
Object.keys(headers).forEach(function (key) {
|
|
3169
|
-
req.setRequestHeader(key, headers[key]);
|
|
3170
|
-
});
|
|
3171
|
-
}
|
|
3172
|
-
req.onreadystatechange = function () {
|
|
3173
|
-
if (req.readyState === 4) {
|
|
3174
|
-
if (req.status === 200) {
|
|
3175
|
-
var response = req.responseText;
|
|
3176
|
-
response && done.call(_this, _this["convert".concat(capitalize(mimeType), "ToData")](mimeType === "json" ? JSON.parse(response) : response, keys));
|
|
3177
|
-
}
|
|
3178
|
-
else {
|
|
3179
|
-
throw new Error("".concat(url, ": Something went wrong loading!"));
|
|
3180
|
-
}
|
|
3181
|
-
}
|
|
3182
|
-
};
|
|
3183
|
-
req.send();
|
|
3184
|
-
},
|
|
3185
|
-
/**
|
|
3186
|
-
* Convert CSV/TSV data
|
|
3187
|
-
* @param {object} parser Parser object
|
|
3188
|
-
* @param {object} xsv Data
|
|
3189
|
-
* @private
|
|
3190
|
-
* @returns {object}
|
|
3191
|
-
*/
|
|
3192
|
-
convertCsvTsvToData: function (parser, xsv) {
|
|
3193
|
-
var rows = parser.rows(xsv);
|
|
3194
|
-
var d;
|
|
3195
|
-
if (rows.length === 1) {
|
|
3196
|
-
d = [{}];
|
|
3197
|
-
rows[0].forEach(function (id) {
|
|
3198
|
-
d[0][id] = null;
|
|
3199
|
-
});
|
|
3200
|
-
}
|
|
3201
|
-
else {
|
|
3202
|
-
d = parser.parse(xsv);
|
|
3203
|
-
}
|
|
3204
|
-
return d;
|
|
3205
|
-
},
|
|
3206
|
-
convertCsvToData: function (xsv) {
|
|
3207
|
-
return this.convertCsvTsvToData({
|
|
3208
|
-
rows: csvParseRows,
|
|
3209
|
-
parse: csvParse
|
|
3210
|
-
}, xsv);
|
|
3211
|
-
},
|
|
3212
|
-
convertTsvToData: function (tsv) {
|
|
3213
|
-
return this.convertCsvTsvToData({
|
|
3214
|
-
rows: tsvParseRows,
|
|
3215
|
-
parse: tsvParse
|
|
3216
|
-
}, tsv);
|
|
3217
|
-
},
|
|
3218
|
-
convertJsonToData: function (json, keysParam) {
|
|
3219
|
-
var _this = this;
|
|
3220
|
-
var config = this.config;
|
|
3221
|
-
var newRows = [];
|
|
3222
|
-
var targetKeys;
|
|
3223
|
-
var data;
|
|
3224
|
-
if (isArray(json)) {
|
|
3225
|
-
var keys = keysParam || config.data_keys;
|
|
3226
|
-
if (keys.x) {
|
|
3227
|
-
targetKeys = keys.value.concat(keys.x);
|
|
3228
|
-
config.data_x = keys.x;
|
|
3229
|
-
}
|
|
3230
|
-
else {
|
|
3231
|
-
targetKeys = keys.value;
|
|
3232
|
-
}
|
|
3233
|
-
newRows.push(targetKeys);
|
|
3234
|
-
json.forEach(function (o) {
|
|
3235
|
-
var newRow = targetKeys.map(function (key) {
|
|
3236
|
-
// convert undefined to null because undefined data will be removed in convertDataToTargets()
|
|
3237
|
-
var v = _this.findValueInJson(o, key);
|
|
3238
|
-
if (isUndefined(v)) {
|
|
3239
|
-
v = null;
|
|
3240
|
-
}
|
|
3241
|
-
return v;
|
|
3242
|
-
});
|
|
3243
|
-
newRows.push(newRow);
|
|
3244
|
-
});
|
|
3245
|
-
data = this.convertRowsToData(newRows);
|
|
3246
|
-
}
|
|
3247
|
-
else {
|
|
3248
|
-
Object.keys(json).forEach(function (key) {
|
|
3249
|
-
var tmp = json[key].concat();
|
|
3250
|
-
tmp.unshift(key);
|
|
3251
|
-
newRows.push(tmp);
|
|
3252
|
-
});
|
|
3253
|
-
data = this.convertColumnsToData(newRows);
|
|
3254
|
-
}
|
|
3255
|
-
return data;
|
|
3256
|
-
},
|
|
3257
|
-
findValueInJson: function (object, path) {
|
|
3258
|
-
if (object[path] !== undefined) {
|
|
3259
|
-
return object[path];
|
|
3260
|
-
}
|
|
3261
|
-
var convertedPath = path.replace(/\[(\w+)\]/g, ".$1"); // convert indexes to properties (replace [] with .)
|
|
3262
|
-
var pathArray = convertedPath.replace(/^\./, "").split("."); // strip a leading dot
|
|
3263
|
-
var target = object;
|
|
3264
|
-
pathArray.some(function (k) { return !(target = target && k in target ?
|
|
3265
|
-
target[k] : undefined); });
|
|
3266
|
-
return target;
|
|
3267
|
-
},
|
|
3268
|
-
convertRowsToData: function (rows) {
|
|
3269
|
-
var keys = rows[0];
|
|
3270
|
-
var newRows = [];
|
|
3271
|
-
rows.forEach(function (row, i) {
|
|
3272
|
-
if (i > 0) {
|
|
3273
|
-
var newRow_1 = {};
|
|
3274
|
-
row.forEach(function (v, j) {
|
|
3275
|
-
if (isUndefined(v)) {
|
|
3276
|
-
throw new Error("Source data is missing a component at (".concat(i, ", ").concat(j, ")!"));
|
|
3277
|
-
}
|
|
3278
|
-
newRow_1[keys[j]] = v;
|
|
3279
|
-
});
|
|
3280
|
-
newRows.push(newRow_1);
|
|
3281
|
-
}
|
|
3282
|
-
});
|
|
3283
|
-
return newRows;
|
|
3284
|
-
},
|
|
3285
|
-
convertColumnsToData: function (columns) {
|
|
3286
|
-
var newRows = [];
|
|
3287
|
-
columns.forEach(function (col, i) {
|
|
3288
|
-
var key = col[0];
|
|
3289
|
-
col.forEach(function (v, j) {
|
|
3290
|
-
if (j > 0) {
|
|
3291
|
-
if (isUndefined(newRows[j - 1])) {
|
|
3292
|
-
newRows[j - 1] = {};
|
|
3293
|
-
}
|
|
3294
|
-
if (isUndefined(v)) {
|
|
3295
|
-
throw new Error("Source data is missing a component at (".concat(i, ", ").concat(j, ")!"));
|
|
3296
|
-
}
|
|
3297
|
-
newRows[j - 1][key] = v;
|
|
3298
|
-
}
|
|
3299
|
-
});
|
|
3300
|
-
});
|
|
3301
|
-
return newRows;
|
|
3302
3498
|
},
|
|
3303
3499
|
convertDataToTargets: function (data, appendXs) {
|
|
3304
3500
|
var _this = this;
|
|
@@ -3356,6 +3552,7 @@ var dataConvert = {
|
|
|
3356
3552
|
var hasCategory = isCategory && data.map(function (v) { return v.x; })
|
|
3357
3553
|
.every(function (v) { return config.axis_x_categories.indexOf(v) > -1; });
|
|
3358
3554
|
// when .load() with 'append' option is used for indexed axis
|
|
3555
|
+
// @ts-ignore
|
|
3359
3556
|
var isDataAppend = data.__append__;
|
|
3360
3557
|
var xIndex = xKey === null && isDataAppend ?
|
|
3361
3558
|
$$.api.data.values(id).length : 0;
|
|
@@ -3386,7 +3583,12 @@ var dataConvert = {
|
|
|
3386
3583
|
if (isUndefined(value) || $$.data.xs[id].length <= i) {
|
|
3387
3584
|
x = undefined;
|
|
3388
3585
|
}
|
|
3389
|
-
return {
|
|
3586
|
+
return {
|
|
3587
|
+
x: x,
|
|
3588
|
+
value: value,
|
|
3589
|
+
id: convertedId,
|
|
3590
|
+
index: -1
|
|
3591
|
+
};
|
|
3390
3592
|
}).filter(function (v) { return isDefined(v.x); })
|
|
3391
3593
|
};
|
|
3392
3594
|
});
|
|
@@ -4277,9 +4479,11 @@ var dataLoad = {
|
|
|
4277
4479
|
}
|
|
4278
4480
|
// reset internally cached data
|
|
4279
4481
|
$$.cache.reset();
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4482
|
+
$$.convertData(args, function (d) {
|
|
4483
|
+
var data = args.data || d;
|
|
4484
|
+
args.append && (data.__append__ = true);
|
|
4485
|
+
data && $$.load($$.convertDataToTargets(data), args);
|
|
4486
|
+
});
|
|
4283
4487
|
},
|
|
4284
4488
|
unload: function (rawTargetIds, customDoneCb) {
|
|
4285
4489
|
var $$ = this;
|
|
@@ -4704,47 +4908,46 @@ var colorizePattern = function (pattern, color, id) {
|
|
|
4704
4908
|
node: node.node()
|
|
4705
4909
|
};
|
|
4706
4910
|
};
|
|
4911
|
+
/**
|
|
4912
|
+
* Get color pattern from CSS file
|
|
4913
|
+
* CSS should be defined as: background-image: url("#00c73c;#fa7171; ...");
|
|
4914
|
+
* @param {d3Selection} element Chart element
|
|
4915
|
+
* @returns {Array}
|
|
4916
|
+
* @private
|
|
4917
|
+
*/
|
|
4918
|
+
function getColorFromCss(element) {
|
|
4919
|
+
var cacheKey = KEY.colorPattern;
|
|
4920
|
+
var body = doc.body;
|
|
4921
|
+
var pattern = body[cacheKey];
|
|
4922
|
+
if (!pattern) {
|
|
4923
|
+
var delimiter = ";";
|
|
4924
|
+
var content = element
|
|
4925
|
+
.classed($COLOR.colorPattern, true)
|
|
4926
|
+
.style("background-image");
|
|
4927
|
+
element.classed($COLOR.colorPattern, false);
|
|
4928
|
+
if (content.indexOf(delimiter) > -1) {
|
|
4929
|
+
pattern = content
|
|
4930
|
+
.replace(/url[^#]*|["'()]|(\s|%20)/g, "")
|
|
4931
|
+
.split(delimiter)
|
|
4932
|
+
.map(function (v) { return v.trim().replace(/[\"'\s]/g, ""); })
|
|
4933
|
+
.filter(Boolean);
|
|
4934
|
+
body[cacheKey] = pattern;
|
|
4935
|
+
}
|
|
4936
|
+
}
|
|
4937
|
+
return pattern;
|
|
4938
|
+
}
|
|
4707
4939
|
// Replacement of d3.schemeCategory10.
|
|
4708
4940
|
// Contained differently depend on d3 version: v4(d3-scale), v5(d3-scale-chromatic)
|
|
4709
4941
|
var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "#8c564b", "#e377c2", "#7f7f7f", "#bcbd22", "#17becf"];
|
|
4710
4942
|
var color = {
|
|
4711
|
-
/**
|
|
4712
|
-
* Get color pattern from CSS file
|
|
4713
|
-
* CSS should be defined as: background-image: url("#00c73c;#fa7171; ...");
|
|
4714
|
-
* @returns {Array}
|
|
4715
|
-
* @private
|
|
4716
|
-
*/
|
|
4717
|
-
getColorFromCss: function () {
|
|
4718
|
-
var cacheKey = KEY.colorPattern;
|
|
4719
|
-
var body = doc.body;
|
|
4720
|
-
var pattern = body[cacheKey];
|
|
4721
|
-
if (!pattern) {
|
|
4722
|
-
var delimiter = ";";
|
|
4723
|
-
var span = doc.createElement("span");
|
|
4724
|
-
span.className = $COLOR.colorPattern;
|
|
4725
|
-
span.style.display = "none";
|
|
4726
|
-
body.appendChild(span);
|
|
4727
|
-
var content = win.getComputedStyle(span).backgroundImage;
|
|
4728
|
-
span.parentNode.removeChild(span);
|
|
4729
|
-
if (content.indexOf(delimiter) > -1) {
|
|
4730
|
-
pattern = content
|
|
4731
|
-
.replace(/url[^#]*|["'()]|(\s|%20)/g, "")
|
|
4732
|
-
.split(delimiter)
|
|
4733
|
-
.map(function (v) { return v.trim().replace(/[\"'\s]/g, ""); })
|
|
4734
|
-
.filter(Boolean);
|
|
4735
|
-
body[cacheKey] = pattern;
|
|
4736
|
-
}
|
|
4737
|
-
}
|
|
4738
|
-
return pattern;
|
|
4739
|
-
},
|
|
4740
4943
|
generateColor: function () {
|
|
4741
4944
|
var $$ = this;
|
|
4742
|
-
var config = $$.config;
|
|
4945
|
+
var $el = $$.$el, config = $$.config;
|
|
4743
4946
|
var colors = config.data_colors;
|
|
4744
4947
|
var callback = config.data_color;
|
|
4745
4948
|
var ids = [];
|
|
4746
4949
|
var pattern = notEmpty(config.color_pattern) ? config.color_pattern :
|
|
4747
|
-
scaleOrdinal(
|
|
4950
|
+
scaleOrdinal(getColorFromCss($el.chart) || schemeCategory10).range();
|
|
4748
4951
|
var originalColorPattern = pattern;
|
|
4749
4952
|
if (isFunction(config.color_tiles)) {
|
|
4750
4953
|
var tiles_1 = config.color_tiles.bind($$.api)();
|
|
@@ -5554,9 +5757,10 @@ var legend$1 = {
|
|
|
5554
5757
|
*/
|
|
5555
5758
|
setLegendItem: function (item) {
|
|
5556
5759
|
var $$ = this;
|
|
5557
|
-
var api = $$.api, config = $$.config, state = $$.state;
|
|
5760
|
+
var $el = $$.$el, api = $$.api, config = $$.config, state = $$.state;
|
|
5558
5761
|
var isTouch = state.inputType === "touch";
|
|
5559
5762
|
var hasGauge = $$.hasType("gauge");
|
|
5763
|
+
var useCssRule = config.boost_useCssRule;
|
|
5560
5764
|
item
|
|
5561
5765
|
.attr("class", function (id) {
|
|
5562
5766
|
var node = select(this);
|
|
@@ -5565,8 +5769,20 @@ var legend$1 = {
|
|
|
5565
5769
|
})
|
|
5566
5770
|
.style("visibility", function (id) { return ($$.isLegendToShow(id) ? null : "hidden"); });
|
|
5567
5771
|
if (config.interaction_enabled) {
|
|
5772
|
+
if (useCssRule) {
|
|
5773
|
+
[
|
|
5774
|
+
[".".concat($LEGEND.legendItem), "cursor:pointer"],
|
|
5775
|
+
[".".concat($LEGEND.legendItem, " text"), "pointer-events:none"],
|
|
5776
|
+
[".".concat($LEGEND.legendItemPoint, " text"), "pointer-events:none"],
|
|
5777
|
+
[".".concat($LEGEND.legendItemTile), "pointer-events:none"],
|
|
5778
|
+
[".".concat($LEGEND.legendItemEvent), "fill-opacity:0"]
|
|
5779
|
+
].forEach(function (v) {
|
|
5780
|
+
var selector = v[0], props = v[1];
|
|
5781
|
+
$$.setCssRule(false, selector, [props])($el.legend);
|
|
5782
|
+
});
|
|
5783
|
+
}
|
|
5568
5784
|
item
|
|
5569
|
-
.style("cursor", "pointer")
|
|
5785
|
+
.style("cursor", $$.getStylePropValue("pointer"))
|
|
5570
5786
|
.on("click", function (event, id) {
|
|
5571
5787
|
if (!callFn(config.legend_item_onclick, api, id)) {
|
|
5572
5788
|
if (event.altKey) {
|
|
@@ -5733,12 +5949,12 @@ var legend$1 = {
|
|
|
5733
5949
|
.each(function (id, i) {
|
|
5734
5950
|
updatePositions(this, id, i);
|
|
5735
5951
|
})
|
|
5736
|
-
.style("pointer-events", "none")
|
|
5952
|
+
.style("pointer-events", $$.getStylePropValue("none"))
|
|
5737
5953
|
.attr("x", isLegendRightOrInset ? xForLegendText : pos)
|
|
5738
5954
|
.attr("y", isLegendRightOrInset ? pos : yForLegendText);
|
|
5739
5955
|
l.append("rect")
|
|
5740
5956
|
.attr("class", $LEGEND.legendItemEvent)
|
|
5741
|
-
.style("fill-opacity", "0")
|
|
5957
|
+
.style("fill-opacity", $$.getStylePropValue("0"))
|
|
5742
5958
|
.attr("x", isLegendRightOrInset ? xForLegendRect : pos)
|
|
5743
5959
|
.attr("y", isLegendRightOrInset ? pos : yForLegendRect);
|
|
5744
5960
|
var getColor = function (id) {
|
|
@@ -5762,7 +5978,7 @@ var legend$1 = {
|
|
|
5762
5978
|
})
|
|
5763
5979
|
.attr("class", $LEGEND.legendItemPoint)
|
|
5764
5980
|
.style("fill", getColor)
|
|
5765
|
-
.style("pointer-events", "none")
|
|
5981
|
+
.style("pointer-events", $$.getStylePropValue("none"))
|
|
5766
5982
|
.attr("href", function (data, idx, selection) {
|
|
5767
5983
|
var node = selection[idx];
|
|
5768
5984
|
var nodeName = node.nodeName.toLowerCase();
|
|
@@ -5774,7 +5990,7 @@ var legend$1 = {
|
|
|
5774
5990
|
l.append("line")
|
|
5775
5991
|
.attr("class", $LEGEND.legendItemTile)
|
|
5776
5992
|
.style("stroke", getColor)
|
|
5777
|
-
.style("pointer-events", "none")
|
|
5993
|
+
.style("pointer-events", $$.getStylePropValue("none"))
|
|
5778
5994
|
.attr("x1", isLegendRightOrInset ? x1ForLegendTile : pos)
|
|
5779
5995
|
.attr("y1", isLegendRightOrInset ? pos : yForLegendTile)
|
|
5780
5996
|
.attr("x2", isLegendRightOrInset ? x2ForLegendTile : pos)
|
|
@@ -6061,6 +6277,10 @@ var redraw = {
|
|
|
6061
6277
|
// Draw with new sizes & scales
|
|
6062
6278
|
$$.redraw(options, transitions);
|
|
6063
6279
|
},
|
|
6280
|
+
/**
|
|
6281
|
+
* Redraw without rescale
|
|
6282
|
+
* @private
|
|
6283
|
+
*/
|
|
6064
6284
|
redrawWithoutRescale: function () {
|
|
6065
6285
|
this.redraw({
|
|
6066
6286
|
withY: false,
|
|
@@ -6209,7 +6429,10 @@ var scale = {
|
|
|
6209
6429
|
var xDomain = updateXDomain && ((_a = scale.x) === null || _a === void 0 ? void 0 : _a.orgDomain());
|
|
6210
6430
|
var xSubDomain = updateXDomain && org.xDomain;
|
|
6211
6431
|
scale.x = $$.getXScale(min.x, max.x, xDomain, function () { return axis.x.tickOffset(); });
|
|
6212
|
-
scale.subX = $$.getXScale(min.x, max.x, xSubDomain, function (d) {
|
|
6432
|
+
scale.subX = $$.getXScale(min.x, max.x, xSubDomain, function (d) {
|
|
6433
|
+
var _a;
|
|
6434
|
+
return (d % 1 ? 0 : ((_a = axis.subX) !== null && _a !== void 0 ? _a : axis.x).tickOffset());
|
|
6435
|
+
});
|
|
6213
6436
|
format.xAxisTick = axis.getXAxisTickFormat();
|
|
6214
6437
|
format.subXAxisTick = axis.getXAxisTickFormat(true);
|
|
6215
6438
|
axis.setAxis("x", scale.x, config.axis_x_tick_outer, isInit);
|
|
@@ -6972,6 +7195,113 @@ var size = {
|
|
|
6972
7195
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
6973
7196
|
* billboard.js project is licensed under the MIT license
|
|
6974
7197
|
*/
|
|
7198
|
+
var style = {
|
|
7199
|
+
/**
|
|
7200
|
+
* Add props color css rule to given selector
|
|
7201
|
+
* @param {boolean} withShape Set shpes' prefix class
|
|
7202
|
+
* @param {string} selector CSS selector
|
|
7203
|
+
* @param {Array} props CSS props list
|
|
7204
|
+
* @param {Function} propsFn Function to retrieve value or determine for props
|
|
7205
|
+
* @returns {Function}
|
|
7206
|
+
* @private
|
|
7207
|
+
*/
|
|
7208
|
+
setCssRule: function (withShape, selector, props, propsFn) {
|
|
7209
|
+
var $$ = this;
|
|
7210
|
+
var config = $$.config, _a = $$.state, cssRule = _a.cssRule, style = _a.style;
|
|
7211
|
+
return config.boost_useCssRule ? function (selection) {
|
|
7212
|
+
selection.each(function (d) {
|
|
7213
|
+
var res = propsFn && (propsFn === null || propsFn === void 0 ? void 0 : propsFn.call($$, d));
|
|
7214
|
+
var shapeSelector = "".concat(withShape ? ".".concat($SHAPE.shapes + $$.getTargetSelectorSuffix(d.id)) : "").concat(selector);
|
|
7215
|
+
(selector in cssRule) && style.sheet.deleteRule(cssRule[shapeSelector]);
|
|
7216
|
+
$$.state.cssRule[shapeSelector] = addCssRules(style, shapeSelector, props.filter(Boolean).map(function (v) { return (isString(res) && v.indexOf(":") === -1 ? "".concat(v, ": ").concat(res) : (v || "")); }));
|
|
7217
|
+
});
|
|
7218
|
+
} : function () { };
|
|
7219
|
+
},
|
|
7220
|
+
/**
|
|
7221
|
+
* Get style prop value
|
|
7222
|
+
* @param {Function|string} v Value
|
|
7223
|
+
* @returns {string|null}
|
|
7224
|
+
* @private
|
|
7225
|
+
*/
|
|
7226
|
+
getStylePropValue: function (v) {
|
|
7227
|
+
var useCssRule = this.config.boost_useCssRule;
|
|
7228
|
+
return useCssRule ? null : isFunction(v) ? v.bind(this) : v;
|
|
7229
|
+
}
|
|
7230
|
+
};
|
|
7231
|
+
|
|
7232
|
+
/**
|
|
7233
|
+
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
7234
|
+
* billboard.js project is licensed under the MIT license
|
|
7235
|
+
*/
|
|
7236
|
+
/**
|
|
7237
|
+
* Get text-anchor according text.labels.rotate angle
|
|
7238
|
+
* @param {number} angle Angle value
|
|
7239
|
+
* @returns {string} Anchor string value
|
|
7240
|
+
* @private
|
|
7241
|
+
*/
|
|
7242
|
+
function getRotateAnchor(angle) {
|
|
7243
|
+
var anchor = "middle";
|
|
7244
|
+
if (angle > 0 && angle <= 170) {
|
|
7245
|
+
anchor = "end";
|
|
7246
|
+
}
|
|
7247
|
+
else if (angle > 190 && angle <= 360) {
|
|
7248
|
+
anchor = "start";
|
|
7249
|
+
}
|
|
7250
|
+
return anchor;
|
|
7251
|
+
}
|
|
7252
|
+
/**
|
|
7253
|
+
* Set rotated position coordinate according text.labels.rotate angle
|
|
7254
|
+
* @param {object} d Data object
|
|
7255
|
+
* @param {object} pos Position object
|
|
7256
|
+
* @param {object} pos.x x coordinate
|
|
7257
|
+
* @param {object} pos.y y coordinate
|
|
7258
|
+
* @param {string} anchor string value
|
|
7259
|
+
* @param {boolean} isRotated If axis is rotated
|
|
7260
|
+
* @param {boolean} isInverted If axis is inverted
|
|
7261
|
+
* @returns {object} x, y coordinate
|
|
7262
|
+
* @private
|
|
7263
|
+
*/
|
|
7264
|
+
function setRotatePos(d, pos, anchor, isRotated, isInverted) {
|
|
7265
|
+
var _a;
|
|
7266
|
+
var $$ = this;
|
|
7267
|
+
var value = d.value;
|
|
7268
|
+
var isCandlestickType = $$.isCandlestickType(d);
|
|
7269
|
+
var isNegative = (isNumber(value) && value < 0) || (isCandlestickType && !((_a = $$.getCandlestickData(d)) === null || _a === void 0 ? void 0 : _a._isUp));
|
|
7270
|
+
var x = pos.x, y = pos.y;
|
|
7271
|
+
var gap = 4;
|
|
7272
|
+
var doubleGap = gap * 2;
|
|
7273
|
+
if (isRotated) {
|
|
7274
|
+
if (anchor === "start") {
|
|
7275
|
+
x += isNegative ? 0 : doubleGap;
|
|
7276
|
+
y += gap;
|
|
7277
|
+
}
|
|
7278
|
+
else if (anchor === "middle") {
|
|
7279
|
+
x += doubleGap;
|
|
7280
|
+
y -= doubleGap;
|
|
7281
|
+
}
|
|
7282
|
+
else if (anchor === "end") {
|
|
7283
|
+
isNegative && (x -= doubleGap);
|
|
7284
|
+
y += gap;
|
|
7285
|
+
}
|
|
7286
|
+
}
|
|
7287
|
+
else {
|
|
7288
|
+
if (anchor === "start") {
|
|
7289
|
+
x += gap;
|
|
7290
|
+
isNegative && (y += doubleGap * 2);
|
|
7291
|
+
}
|
|
7292
|
+
else if (anchor === "middle") {
|
|
7293
|
+
y -= doubleGap;
|
|
7294
|
+
}
|
|
7295
|
+
else if (anchor === "end") {
|
|
7296
|
+
x -= gap;
|
|
7297
|
+
isNegative && (y += doubleGap * 2);
|
|
7298
|
+
}
|
|
7299
|
+
if (isInverted) {
|
|
7300
|
+
y += isNegative ? -17 : (isCandlestickType ? 13 : 7);
|
|
7301
|
+
}
|
|
7302
|
+
}
|
|
7303
|
+
return { x: x, y: y };
|
|
7304
|
+
}
|
|
6975
7305
|
var text = {
|
|
6976
7306
|
opacityForText: function (d) {
|
|
6977
7307
|
var $$ = this;
|
|
@@ -7002,7 +7332,7 @@ var text = {
|
|
|
7002
7332
|
var mainTextEnter = mainTextUpdate.enter().append("g")
|
|
7003
7333
|
.style("opacity", "0")
|
|
7004
7334
|
.attr("class", classChartText)
|
|
7005
|
-
.
|
|
7335
|
+
.call($$.setCssRule(true, " .".concat($TEXT.text), ["fill", "pointer-events:none"], $$.updateTextColor));
|
|
7006
7336
|
mainTextEnter.append("g")
|
|
7007
7337
|
.attr("class", classTexts);
|
|
7008
7338
|
},
|
|
@@ -7033,7 +7363,7 @@ var text = {
|
|
|
7033
7363
|
}
|
|
7034
7364
|
return (config.axis_rotated ? (isEndAnchor ? "end" : "start") : "middle");
|
|
7035
7365
|
})
|
|
7036
|
-
.style("fill", $$.updateTextColor
|
|
7366
|
+
.style("fill", $$.getStylePropValue($$.updateTextColor))
|
|
7037
7367
|
.style("fill-opacity", "0")
|
|
7038
7368
|
.each(function (d, i, texts) {
|
|
7039
7369
|
var node = select(this);
|
|
@@ -7103,32 +7433,43 @@ var text = {
|
|
|
7103
7433
|
},
|
|
7104
7434
|
/**
|
|
7105
7435
|
* Redraw chartText
|
|
7106
|
-
* @param {Function}
|
|
7107
|
-
* @param {Function}
|
|
7436
|
+
* @param {Function} getX Positioning function for x
|
|
7437
|
+
* @param {Function} getY Positioning function for y
|
|
7108
7438
|
* @param {boolean} forFlow Weather is flow
|
|
7109
7439
|
* @param {boolean} withTransition transition is enabled
|
|
7110
7440
|
* @returns {Array}
|
|
7111
7441
|
* @private
|
|
7112
7442
|
*/
|
|
7113
|
-
redrawText: function (
|
|
7443
|
+
redrawText: function (getX, getY, forFlow, withTransition) {
|
|
7114
7444
|
var $$ = this;
|
|
7115
|
-
var $T = $$.$T;
|
|
7445
|
+
var $T = $$.$T, axis = $$.axis, config = $$.config;
|
|
7116
7446
|
var t = getRandom(true);
|
|
7447
|
+
var isRotated = config.axis_rotated;
|
|
7448
|
+
var angle = config.data_labels.rotate;
|
|
7449
|
+
var anchorString = getRotateAnchor(angle);
|
|
7450
|
+
var rotateString = angle ? "rotate(".concat(angle, ")") : "";
|
|
7117
7451
|
$$.$el.text
|
|
7118
|
-
.style("fill", $$.updateTextColor
|
|
7452
|
+
.style("fill", $$.getStylePropValue($$.updateTextColor))
|
|
7119
7453
|
.attr("filter", $$.updateTextBacgroundColor.bind($$))
|
|
7120
7454
|
.style("fill-opacity", forFlow ? 0 : $$.opacityForText.bind($$))
|
|
7121
7455
|
.each(function (d, i) {
|
|
7122
7456
|
// do not apply transition for newly added text elements
|
|
7123
7457
|
var node = $T(this, !!(withTransition && this.getAttribute("x")), t);
|
|
7124
|
-
var
|
|
7125
|
-
var
|
|
7458
|
+
var isInverted = config["axis_".concat(axis === null || axis === void 0 ? void 0 : axis.getId(d.id), "_inverted")];
|
|
7459
|
+
var pos = {
|
|
7460
|
+
x: getX.bind(this)(d, i),
|
|
7461
|
+
y: getY.bind(this)(d, i)
|
|
7462
|
+
};
|
|
7463
|
+
if (angle) {
|
|
7464
|
+
pos = setRotatePos.bind($$)(d, pos, anchorString, isRotated, isInverted);
|
|
7465
|
+
node.attr("text-anchor", anchorString);
|
|
7466
|
+
}
|
|
7126
7467
|
// when is multiline
|
|
7127
|
-
if (this.childElementCount) {
|
|
7128
|
-
node.attr("transform", "translate(".concat(
|
|
7468
|
+
if (this.childElementCount || angle) {
|
|
7469
|
+
node.attr("transform", "translate(".concat(pos.x, " ").concat(pos.y, ") ").concat(rotateString));
|
|
7129
7470
|
}
|
|
7130
7471
|
else {
|
|
7131
|
-
node.attr("x",
|
|
7472
|
+
node.attr("x", pos.x).attr("y", pos.y);
|
|
7132
7473
|
}
|
|
7133
7474
|
});
|
|
7134
7475
|
// need to return 'true' as of being pushed to the redraw list
|
|
@@ -7287,8 +7628,10 @@ var text = {
|
|
|
7287
7628
|
*/
|
|
7288
7629
|
getYForText: function (points, d, textElement) {
|
|
7289
7630
|
var $$ = this;
|
|
7290
|
-
var config = $$.config, state = $$.state;
|
|
7631
|
+
var axis = $$.axis, config = $$.config, state = $$.state;
|
|
7291
7632
|
var isRotated = config.axis_rotated;
|
|
7633
|
+
var isInverted = config["axis_".concat(axis === null || axis === void 0 ? void 0 : axis.getId(d.id), "_inverted")];
|
|
7634
|
+
var isBarType = $$.isBarType(d);
|
|
7292
7635
|
var r = config.point_r;
|
|
7293
7636
|
var rect = getBoundingRect(textElement);
|
|
7294
7637
|
var value = d.value;
|
|
@@ -7304,6 +7647,9 @@ var text = {
|
|
|
7304
7647
|
yPos = value && value._isUp ?
|
|
7305
7648
|
points[2][2] - baseY :
|
|
7306
7649
|
points[2][1] + (baseY * 4);
|
|
7650
|
+
if (isInverted) {
|
|
7651
|
+
yPos += 15 * (value._isUp ? 1 : -1);
|
|
7652
|
+
}
|
|
7307
7653
|
}
|
|
7308
7654
|
}
|
|
7309
7655
|
else {
|
|
@@ -7316,16 +7662,19 @@ var text = {
|
|
|
7316
7662
|
baseY += config.point_r / 2.3;
|
|
7317
7663
|
}
|
|
7318
7664
|
if (value < 0 || (value === 0 && !state.hasPositiveValue && state.hasNegativeValue)) {
|
|
7319
|
-
yPos += rect.height + (
|
|
7665
|
+
yPos += isInverted ? (isBarType ? -3 : -5) : (rect.height + (isBarType ? -baseY : baseY));
|
|
7320
7666
|
}
|
|
7321
7667
|
else {
|
|
7322
7668
|
var diff = -baseY * 2;
|
|
7323
|
-
if (
|
|
7669
|
+
if (isBarType) {
|
|
7324
7670
|
diff = -baseY;
|
|
7325
7671
|
}
|
|
7326
7672
|
else if ($$.isBubbleType(d)) {
|
|
7327
7673
|
diff = baseY;
|
|
7328
7674
|
}
|
|
7675
|
+
if (isInverted) {
|
|
7676
|
+
diff = isBarType ? 10 : 15;
|
|
7677
|
+
}
|
|
7329
7678
|
yPos += diff;
|
|
7330
7679
|
}
|
|
7331
7680
|
}
|
|
@@ -8311,17 +8660,25 @@ var ChartInternal = /** @class */ (function () {
|
|
|
8311
8660
|
ChartInternal.prototype.init = function () {
|
|
8312
8661
|
var $$ = this;
|
|
8313
8662
|
var config = $$.config, state = $$.state, $el = $$.$el;
|
|
8663
|
+
var useCssRule = config.boost_useCssRule;
|
|
8314
8664
|
checkModuleImport($$);
|
|
8315
8665
|
state.hasAxis = !$$.hasArcType();
|
|
8316
8666
|
state.hasRadar = !state.hasAxis && $$.hasType("radar");
|
|
8317
|
-
//
|
|
8318
|
-
|
|
8319
|
-
|
|
8320
|
-
|
|
8321
|
-
|
|
8322
|
-
|
|
8667
|
+
// datetime to be used for uniqueness
|
|
8668
|
+
state.datetimeId = "bb-".concat(+new Date() * getRandom());
|
|
8669
|
+
if (useCssRule) {
|
|
8670
|
+
// append style element
|
|
8671
|
+
var styleEl = doc.createElement("style");
|
|
8672
|
+
// styleEl.id = styleId;
|
|
8673
|
+
styleEl.type = "text/css";
|
|
8674
|
+
doc.head.appendChild(styleEl);
|
|
8675
|
+
state.style = {
|
|
8676
|
+
rootSelctor: ".".concat(state.datetimeId),
|
|
8677
|
+
sheet: styleEl.sheet
|
|
8678
|
+
};
|
|
8679
|
+
// used on .destroy()
|
|
8680
|
+
$el.style = styleEl;
|
|
8323
8681
|
}
|
|
8324
|
-
$$.initParams();
|
|
8325
8682
|
var bindto = {
|
|
8326
8683
|
element: config.bindto,
|
|
8327
8684
|
classname: "bb"
|
|
@@ -8338,7 +8695,9 @@ var ChartInternal = /** @class */ (function () {
|
|
|
8338
8695
|
}
|
|
8339
8696
|
$el.chart.html("")
|
|
8340
8697
|
.classed(bindto.classname, true)
|
|
8698
|
+
.classed(state.datetimeId, useCssRule)
|
|
8341
8699
|
.style("position", "relative");
|
|
8700
|
+
$$.initParams();
|
|
8342
8701
|
$$.initToRender();
|
|
8343
8702
|
};
|
|
8344
8703
|
/**
|
|
@@ -8364,19 +8723,26 @@ var ChartInternal = /** @class */ (function () {
|
|
|
8364
8723
|
});
|
|
8365
8724
|
}
|
|
8366
8725
|
if (!isLazy || forced) {
|
|
8367
|
-
|
|
8368
|
-
|
|
8369
|
-
|
|
8726
|
+
$$.convertData(config, function (res) {
|
|
8727
|
+
$$.initWithData(res);
|
|
8728
|
+
$$.afterInit();
|
|
8729
|
+
});
|
|
8370
8730
|
}
|
|
8371
8731
|
};
|
|
8372
8732
|
ChartInternal.prototype.initParams = function () {
|
|
8373
8733
|
var $$ = this;
|
|
8374
8734
|
var config = $$.config, format = $$.format, state = $$.state;
|
|
8375
8735
|
var isRotated = config.axis_rotated;
|
|
8376
|
-
//
|
|
8377
|
-
state.datetimeId = "bb-".concat(+new Date() * getRandom());
|
|
8736
|
+
// color settings
|
|
8378
8737
|
$$.color = $$.generateColor();
|
|
8379
8738
|
$$.levelColor = $$.generateLevelColor();
|
|
8739
|
+
// when 'padding=false' is set, disable axes and subchart. Because they are useless.
|
|
8740
|
+
if (config.padding === false) {
|
|
8741
|
+
config.axis_x_show = false;
|
|
8742
|
+
config.axis_y_show = false;
|
|
8743
|
+
config.axis_y2_show = false;
|
|
8744
|
+
config.subchart_show = false;
|
|
8745
|
+
}
|
|
8380
8746
|
if ($$.hasPointType()) {
|
|
8381
8747
|
$$.point = $$.generatePoint();
|
|
8382
8748
|
}
|
|
@@ -8729,17 +9095,22 @@ var ChartInternal = /** @class */ (function () {
|
|
|
8729
9095
|
ChartInternal.prototype.bindResize = function () {
|
|
8730
9096
|
var $$ = this;
|
|
8731
9097
|
var config = $$.config, state = $$.state;
|
|
8732
|
-
var resizeFunction = generateResize();
|
|
9098
|
+
var resizeFunction = generateResize(config.resize_timer);
|
|
8733
9099
|
var list = [];
|
|
8734
|
-
list.push(function () { return callFn(config.onresize,
|
|
9100
|
+
list.push(function () { return callFn(config.onresize, $$.api); });
|
|
8735
9101
|
if (config.resize_auto) {
|
|
8736
9102
|
list.push(function () {
|
|
8737
9103
|
state.resizing = true;
|
|
9104
|
+
// https://github.com/naver/billboard.js/issues/2650
|
|
9105
|
+
if (config.legend_show) {
|
|
9106
|
+
$$.updateSizes();
|
|
9107
|
+
$$.updateLegend();
|
|
9108
|
+
}
|
|
8738
9109
|
$$.api.flush(false);
|
|
8739
9110
|
});
|
|
8740
9111
|
}
|
|
8741
9112
|
list.push(function () {
|
|
8742
|
-
callFn(config.onresized,
|
|
9113
|
+
callFn(config.onresized, $$.api);
|
|
8743
9114
|
state.resizing = false;
|
|
8744
9115
|
});
|
|
8745
9116
|
// add resize functions
|
|
@@ -8786,6 +9157,7 @@ extend(ChartInternal.prototype, [
|
|
|
8786
9157
|
scale,
|
|
8787
9158
|
shape,
|
|
8788
9159
|
size,
|
|
9160
|
+
style,
|
|
8789
9161
|
text,
|
|
8790
9162
|
title,
|
|
8791
9163
|
tooltip$1,
|
|
@@ -8922,7 +9294,7 @@ var apiChart = {
|
|
|
8922
9294
|
destroy: function () {
|
|
8923
9295
|
var _this = this;
|
|
8924
9296
|
var $$ = this.internal;
|
|
8925
|
-
var _a = $$.$el, chart = _a.chart, svg = _a.svg;
|
|
9297
|
+
var _a = $$.$el, chart = _a.chart, style = _a.style, svg = _a.svg;
|
|
8926
9298
|
if (notEmpty($$)) {
|
|
8927
9299
|
$$.callPluginHook("$willDestroy");
|
|
8928
9300
|
$$.charts.splice($$.charts.indexOf(this), 1);
|
|
@@ -8936,6 +9308,8 @@ var apiChart = {
|
|
|
8936
9308
|
.style("position", null)
|
|
8937
9309
|
.selectChildren()
|
|
8938
9310
|
.remove();
|
|
9311
|
+
// remove <style> element added by boost.useCssRule option
|
|
9312
|
+
style && style.parentNode.removeChild(style);
|
|
8939
9313
|
// releasing own references
|
|
8940
9314
|
Object.keys(this).forEach(function (key) {
|
|
8941
9315
|
key === "internal" && Object.keys($$).forEach(function (k) {
|
|
@@ -9091,7 +9465,7 @@ extend(data, {
|
|
|
9091
9465
|
* @function data․names
|
|
9092
9466
|
* @instance
|
|
9093
9467
|
* @memberof Chart
|
|
9094
|
-
* @param {object} names If this argument is given, the names of data will be updated. If not given, the current names will be returned. The format of this argument is the same as
|
|
9468
|
+
* @param {object} names If this argument is given, the names of data will be updated. If not given, the current names will be returned. The format of this argument is the same as [data.names](./Options.html#.data%25E2%2580%25A4names).
|
|
9095
9469
|
* @returns {object} Corresponding names according its key value, if specified names values.
|
|
9096
9470
|
* @example
|
|
9097
9471
|
* // Get current names
|
|
@@ -10736,130 +11110,139 @@ var apiFlow = {
|
|
|
10736
11110
|
flow: function (args) {
|
|
10737
11111
|
var $$ = this.internal;
|
|
10738
11112
|
var data;
|
|
10739
|
-
var domain;
|
|
10740
|
-
var length = 0;
|
|
10741
|
-
var tail = 0;
|
|
10742
|
-
var diff;
|
|
10743
|
-
var to;
|
|
10744
11113
|
if (args.json || args.rows || args.columns) {
|
|
10745
|
-
|
|
10746
|
-
|
|
10747
|
-
|
|
10748
|
-
|
|
11114
|
+
$$.convertData(args, function (res) {
|
|
11115
|
+
data = res;
|
|
11116
|
+
_();
|
|
11117
|
+
});
|
|
10749
11118
|
}
|
|
10750
|
-
|
|
10751
|
-
|
|
10752
|
-
|
|
10753
|
-
|
|
10754
|
-
|
|
10755
|
-
|
|
10756
|
-
var
|
|
10757
|
-
|
|
10758
|
-
|
|
10759
|
-
|
|
10760
|
-
|
|
10761
|
-
|
|
11119
|
+
/**
|
|
11120
|
+
* Process flows
|
|
11121
|
+
* @private
|
|
11122
|
+
*/
|
|
11123
|
+
function _() {
|
|
11124
|
+
var domain;
|
|
11125
|
+
var length = 0;
|
|
11126
|
+
var tail = 0;
|
|
11127
|
+
var diff;
|
|
11128
|
+
var to;
|
|
11129
|
+
if ($$.state.redrawing || !data || !isTabVisible()) {
|
|
11130
|
+
return;
|
|
11131
|
+
}
|
|
11132
|
+
var notfoundIds = [];
|
|
11133
|
+
var orgDataCount = $$.getMaxDataCount();
|
|
11134
|
+
var targets = $$.convertDataToTargets(data, true);
|
|
11135
|
+
var isTimeSeries = $$.axis.isTimeSeries();
|
|
11136
|
+
// Update/Add data
|
|
11137
|
+
$$.data.targets.forEach(function (t) {
|
|
11138
|
+
var found = false;
|
|
11139
|
+
for (var i = 0; i < targets.length; i++) {
|
|
11140
|
+
if (t.id === targets[i].id) {
|
|
11141
|
+
found = true;
|
|
11142
|
+
if (t.values[t.values.length - 1]) {
|
|
11143
|
+
tail = t.values[t.values.length - 1].index + 1;
|
|
11144
|
+
}
|
|
11145
|
+
length = targets[i].values.length;
|
|
11146
|
+
for (var j = 0; j < length; j++) {
|
|
11147
|
+
targets[i].values[j].index = tail + j;
|
|
11148
|
+
if (!isTimeSeries) {
|
|
11149
|
+
targets[i].values[j].x = tail + j;
|
|
11150
|
+
}
|
|
11151
|
+
}
|
|
11152
|
+
t.values = t.values.concat(targets[i].values);
|
|
11153
|
+
targets.splice(i, 1);
|
|
11154
|
+
break;
|
|
10762
11155
|
}
|
|
10763
|
-
|
|
10764
|
-
|
|
10765
|
-
|
|
10766
|
-
|
|
10767
|
-
|
|
11156
|
+
}
|
|
11157
|
+
!found && notfoundIds.push(t.id);
|
|
11158
|
+
});
|
|
11159
|
+
// Append null for not found targets
|
|
11160
|
+
$$.data.targets.forEach(function (t) {
|
|
11161
|
+
for (var i = 0; i < notfoundIds.length; i++) {
|
|
11162
|
+
if (t.id === notfoundIds[i]) {
|
|
11163
|
+
tail = t.values[t.values.length - 1].index + 1;
|
|
11164
|
+
for (var j = 0; j < length; j++) {
|
|
11165
|
+
t.values.push({
|
|
11166
|
+
id: t.id,
|
|
11167
|
+
index: tail + j,
|
|
11168
|
+
x: isTimeSeries ? $$.getOtherTargetX(tail + j) : tail + j,
|
|
11169
|
+
value: null
|
|
11170
|
+
});
|
|
10768
11171
|
}
|
|
10769
11172
|
}
|
|
10770
|
-
t.values = t.values.concat(targets[i].values);
|
|
10771
|
-
targets.splice(i, 1);
|
|
10772
|
-
break;
|
|
10773
11173
|
}
|
|
10774
|
-
}
|
|
10775
|
-
|
|
10776
|
-
|
|
10777
|
-
|
|
10778
|
-
|
|
10779
|
-
|
|
10780
|
-
|
|
10781
|
-
tail = t.values[t.values.length - 1].index + 1;
|
|
10782
|
-
for (var j = 0; j < length; j++) {
|
|
10783
|
-
t.values.push({
|
|
11174
|
+
});
|
|
11175
|
+
// Generate null values for new target
|
|
11176
|
+
if ($$.data.targets.length) {
|
|
11177
|
+
targets.forEach(function (t) {
|
|
11178
|
+
var missing = [];
|
|
11179
|
+
for (var i = $$.data.targets[0].values[0].index; i < tail; i++) {
|
|
11180
|
+
missing.push({
|
|
10784
11181
|
id: t.id,
|
|
10785
|
-
index:
|
|
10786
|
-
x: isTimeSeries ? $$.getOtherTargetX(
|
|
11182
|
+
index: i,
|
|
11183
|
+
x: isTimeSeries ? $$.getOtherTargetX(i) : i,
|
|
10787
11184
|
value: null
|
|
10788
11185
|
});
|
|
10789
11186
|
}
|
|
10790
|
-
|
|
10791
|
-
|
|
10792
|
-
|
|
10793
|
-
|
|
10794
|
-
|
|
10795
|
-
targets.forEach(function (t) {
|
|
10796
|
-
var missing = [];
|
|
10797
|
-
for (var i = $$.data.targets[0].values[0].index; i < tail; i++) {
|
|
10798
|
-
missing.push({
|
|
10799
|
-
id: t.id,
|
|
10800
|
-
index: i,
|
|
10801
|
-
x: isTimeSeries ? $$.getOtherTargetX(i) : i,
|
|
10802
|
-
value: null
|
|
11187
|
+
t.values.forEach(function (v) {
|
|
11188
|
+
v.index += tail;
|
|
11189
|
+
if (!isTimeSeries) {
|
|
11190
|
+
v.x += tail;
|
|
11191
|
+
}
|
|
10803
11192
|
});
|
|
10804
|
-
|
|
10805
|
-
t.values.forEach(function (v) {
|
|
10806
|
-
v.index += tail;
|
|
10807
|
-
if (!isTimeSeries) {
|
|
10808
|
-
v.x += tail;
|
|
10809
|
-
}
|
|
11193
|
+
t.values = missing.concat(t.values);
|
|
10810
11194
|
});
|
|
10811
|
-
t.values = missing.concat(t.values);
|
|
10812
|
-
});
|
|
10813
|
-
}
|
|
10814
|
-
$$.data.targets = $$.data.targets.concat(targets); // add remained
|
|
10815
|
-
// check data count because behavior needs to change when it"s only one
|
|
10816
|
-
// const dataCount = $$.getMaxDataCount();
|
|
10817
|
-
var baseTarget = $$.data.targets[0];
|
|
10818
|
-
var baseValue = baseTarget.values[0];
|
|
10819
|
-
// Update length to flow if needed
|
|
10820
|
-
if (isDefined(args.to)) {
|
|
10821
|
-
length = 0;
|
|
10822
|
-
to = isTimeSeries ? parseDate.call($$, args.to) : args.to;
|
|
10823
|
-
baseTarget.values.forEach(function (v) {
|
|
10824
|
-
v.x < to && length++;
|
|
10825
|
-
});
|
|
10826
|
-
}
|
|
10827
|
-
else if (isDefined(args.length)) {
|
|
10828
|
-
length = args.length;
|
|
10829
|
-
}
|
|
10830
|
-
// If only one data, update the domain to flow from left edge of the chart
|
|
10831
|
-
if (!orgDataCount) {
|
|
10832
|
-
if (isTimeSeries) {
|
|
10833
|
-
diff = baseTarget.values.length > 1 ?
|
|
10834
|
-
baseTarget.values[baseTarget.values.length - 1].x - baseValue.x :
|
|
10835
|
-
baseValue.x - $$.getXDomain($$.data.targets)[0];
|
|
10836
11195
|
}
|
|
10837
|
-
|
|
10838
|
-
|
|
11196
|
+
$$.data.targets = $$.data.targets.concat(targets); // add remained
|
|
11197
|
+
// check data count because behavior needs to change when it"s only one
|
|
11198
|
+
// const dataCount = $$.getMaxDataCount();
|
|
11199
|
+
var baseTarget = $$.data.targets[0];
|
|
11200
|
+
var baseValue = baseTarget.values[0];
|
|
11201
|
+
// Update length to flow if needed
|
|
11202
|
+
if (isDefined(args.to)) {
|
|
11203
|
+
length = 0;
|
|
11204
|
+
to = isTimeSeries ? parseDate.call($$, args.to) : args.to;
|
|
11205
|
+
baseTarget.values.forEach(function (v) {
|
|
11206
|
+
v.x < to && length++;
|
|
11207
|
+
});
|
|
10839
11208
|
}
|
|
10840
|
-
|
|
10841
|
-
|
|
10842
|
-
|
|
10843
|
-
|
|
10844
|
-
|
|
11209
|
+
else if (isDefined(args.length)) {
|
|
11210
|
+
length = args.length;
|
|
11211
|
+
}
|
|
11212
|
+
// If only one data, update the domain to flow from left edge of the chart
|
|
11213
|
+
if (!orgDataCount) {
|
|
11214
|
+
if (isTimeSeries) {
|
|
11215
|
+
diff = baseTarget.values.length > 1 ?
|
|
11216
|
+
baseTarget.values[baseTarget.values.length - 1].x - baseValue.x :
|
|
11217
|
+
baseValue.x - $$.getXDomain($$.data.targets)[0];
|
|
11218
|
+
}
|
|
11219
|
+
else {
|
|
11220
|
+
diff = 1;
|
|
11221
|
+
}
|
|
11222
|
+
domain = [baseValue.x - diff, baseValue.x];
|
|
11223
|
+
}
|
|
11224
|
+
else if (orgDataCount === 1 && isTimeSeries) {
|
|
11225
|
+
diff = (baseTarget.values[baseTarget.values.length - 1].x - baseValue.x) / 2;
|
|
11226
|
+
domain = [new Date(+baseValue.x - diff), new Date(+baseValue.x + diff)];
|
|
11227
|
+
}
|
|
11228
|
+
domain && $$.updateXDomain(null, true, true, false, domain);
|
|
11229
|
+
// Set targets
|
|
11230
|
+
$$.updateTargets($$.data.targets);
|
|
11231
|
+
// Redraw with new targets
|
|
11232
|
+
$$.redraw({
|
|
11233
|
+
flow: {
|
|
11234
|
+
index: baseValue.index,
|
|
11235
|
+
length: length,
|
|
11236
|
+
duration: isValue(args.duration) ? args.duration : $$.config.transition_duration,
|
|
11237
|
+
done: args.done,
|
|
11238
|
+
orgDataCount: orgDataCount
|
|
11239
|
+
},
|
|
11240
|
+
withLegend: true,
|
|
11241
|
+
withTransition: orgDataCount > 1,
|
|
11242
|
+
withTrimXDomain: false,
|
|
11243
|
+
withUpdateXAxis: true
|
|
11244
|
+
});
|
|
10845
11245
|
}
|
|
10846
|
-
domain && $$.updateXDomain(null, true, true, false, domain);
|
|
10847
|
-
// Set targets
|
|
10848
|
-
$$.updateTargets($$.data.targets);
|
|
10849
|
-
// Redraw with new targets
|
|
10850
|
-
$$.redraw({
|
|
10851
|
-
flow: {
|
|
10852
|
-
index: baseValue.index,
|
|
10853
|
-
length: length,
|
|
10854
|
-
duration: isValue(args.duration) ? args.duration : $$.config.transition_duration,
|
|
10855
|
-
done: args.done,
|
|
10856
|
-
orgDataCount: orgDataCount
|
|
10857
|
-
},
|
|
10858
|
-
withLegend: true,
|
|
10859
|
-
withTransition: orgDataCount > 1,
|
|
10860
|
-
withTrimXDomain: false,
|
|
10861
|
-
withUpdateXAxis: true
|
|
10862
|
-
});
|
|
10863
11246
|
}
|
|
10864
11247
|
};
|
|
10865
11248
|
|
|
@@ -11049,10 +11432,10 @@ var AxisRenderer = /** @class */ (function () {
|
|
|
11049
11432
|
*/
|
|
11050
11433
|
AxisRenderer.prototype.create = function (g) {
|
|
11051
11434
|
var ctx = this;
|
|
11052
|
-
var
|
|
11435
|
+
var config = ctx.config, helper = ctx.helper, params = ctx.params;
|
|
11053
11436
|
var scale = helper.scale;
|
|
11054
11437
|
var orient = config.orient;
|
|
11055
|
-
var splitTickText = this.splitTickText.bind(
|
|
11438
|
+
var splitTickText = this.splitTickText.bind(ctx);
|
|
11056
11439
|
var isLeftRight = /^(left|right)$/.test(orient);
|
|
11057
11440
|
var isTopBottom = /^(top|bottom)$/.test(orient);
|
|
11058
11441
|
// line/text enter and path update
|
|
@@ -11101,6 +11484,8 @@ var AxisRenderer = /** @class */ (function () {
|
|
|
11101
11484
|
if (tickShow.tick || tickShow.text) {
|
|
11102
11485
|
// count of tick data in array
|
|
11103
11486
|
var ticks_1 = config.tickValues || helper.generateTicks(scale1, isLeftRight);
|
|
11487
|
+
// set generated ticks
|
|
11488
|
+
ctx.generatedTicks = ticks_1;
|
|
11104
11489
|
// update selection
|
|
11105
11490
|
var tick = g.selectAll(".tick")
|
|
11106
11491
|
.data(ticks_1, scale1);
|
|
@@ -11189,6 +11574,24 @@ var AxisRenderer = /** @class */ (function () {
|
|
|
11189
11574
|
});
|
|
11190
11575
|
this.g = $g;
|
|
11191
11576
|
};
|
|
11577
|
+
/**
|
|
11578
|
+
* Get generated ticks
|
|
11579
|
+
* @param {number} count Count of ticks
|
|
11580
|
+
* @returns {Array} Generated ticks
|
|
11581
|
+
* @private
|
|
11582
|
+
*/
|
|
11583
|
+
AxisRenderer.prototype.getGeneratedTicks = function (count) {
|
|
11584
|
+
var len = this.generatedTicks.length - 1;
|
|
11585
|
+
var res = this.generatedTicks;
|
|
11586
|
+
if (len > count) {
|
|
11587
|
+
var interval_1 = Math.round((len / count) - 0.1);
|
|
11588
|
+
res = this.generatedTicks
|
|
11589
|
+
.map(function (v, i) { return (i % interval_1 === 0 ? v : null); })
|
|
11590
|
+
.filter(function (v) { return v !== null; })
|
|
11591
|
+
.splice(0, count);
|
|
11592
|
+
}
|
|
11593
|
+
return res;
|
|
11594
|
+
};
|
|
11192
11595
|
/**
|
|
11193
11596
|
* Get tick x/y coordinate
|
|
11194
11597
|
* @returns {{x: number, y: number}}
|
|
@@ -13091,10 +13494,10 @@ var grid = {
|
|
|
13091
13494
|
},
|
|
13092
13495
|
updateYGrid: function () {
|
|
13093
13496
|
var $$ = this;
|
|
13094
|
-
var config = $$.config, state = $$.state, _a = $$.$el, grid = _a.grid, main = _a.main;
|
|
13497
|
+
var axis = $$.axis, config = $$.config, scale = $$.scale, state = $$.state, _a = $$.$el, grid = _a.grid, main = _a.main;
|
|
13095
13498
|
var isRotated = config.axis_rotated;
|
|
13096
|
-
var
|
|
13097
|
-
var
|
|
13499
|
+
var pos = function (d) { return Math.ceil(scale.y(d)); };
|
|
13500
|
+
var gridValues = axis.y.getGeneratedTicks(config.grid_y_ticks) || $$.scale.y.ticks(config.grid_y_ticks);
|
|
13098
13501
|
grid.y = main.select(".".concat($GRID.ygrids))
|
|
13099
13502
|
.selectAll(".".concat($GRID.ygrid))
|
|
13100
13503
|
.data(gridValues);
|
|
@@ -13533,8 +13936,9 @@ var sizeAxis = {
|
|
|
13533
13936
|
var $$ = this;
|
|
13534
13937
|
if ($$.axis) {
|
|
13535
13938
|
var position = (_a = $$.axis) === null || _a === void 0 ? void 0 : _a.getLabelPositionById(id);
|
|
13536
|
-
|
|
13537
|
-
|
|
13939
|
+
var width = $$.axis.getMaxTickWidth(id, withoutRecompute);
|
|
13940
|
+
var gap = width === 0 ? 0.5 : 0;
|
|
13941
|
+
return width + (position.isInner ? (20 + gap) : 40);
|
|
13538
13942
|
}
|
|
13539
13943
|
else {
|
|
13540
13944
|
return 40;
|
|
@@ -15893,15 +16297,16 @@ var shapeArc = {
|
|
|
15893
16297
|
.data($$.pie(targets))
|
|
15894
16298
|
.attr("class", function (d) { return classChartArc(d) + classFocus(d.data); });
|
|
15895
16299
|
var mainPieEnter = mainPieUpdate.enter().append("g")
|
|
15896
|
-
.attr("class", classChartArc)
|
|
16300
|
+
.attr("class", classChartArc)
|
|
16301
|
+
.call(this.setCssRule(false, ".".concat($ARC.chartArcs, " text"), ["pointer-events:none", "text-anchor:middle"]));
|
|
15897
16302
|
mainPieEnter.append("g")
|
|
15898
16303
|
.attr("class", classArcs)
|
|
15899
16304
|
.merge(mainPieUpdate);
|
|
15900
16305
|
mainPieEnter.append("text")
|
|
15901
16306
|
.attr("dy", hasGauge && !$$.hasMultiTargets() ? "-.1em" : ".35em")
|
|
15902
16307
|
.style("opacity", "0")
|
|
15903
|
-
.style("text-anchor", "middle")
|
|
15904
|
-
.style("pointer-events", "none");
|
|
16308
|
+
.style("text-anchor", $$.getStylePropValue("middle"))
|
|
16309
|
+
.style("pointer-events", $$.getStylePropValue("none"));
|
|
15905
16310
|
$el.text = chartArcs.selectAll(".".concat($COMMON.target, " text"));
|
|
15906
16311
|
// MEMO: can not keep same color..., but not bad to update color in redraw
|
|
15907
16312
|
// mainPieUpdate.exit().remove();
|
|
@@ -16319,8 +16724,7 @@ var shapeArea = {
|
|
|
16319
16724
|
.x0(value0)
|
|
16320
16725
|
.x1(value1) :
|
|
16321
16726
|
area.x(xValue)
|
|
16322
|
-
|
|
16323
|
-
.y0(config.area_above ? 0 : value0)
|
|
16727
|
+
.y0(config.area_above ? 0 : (config.area_below ? $$.state.height : value0))
|
|
16324
16728
|
.y1(value1);
|
|
16325
16729
|
if (!lineConnectNull) {
|
|
16326
16730
|
area = area.defined(function (d) { return $$.getBaseValue(d) !== null; });
|
|
@@ -16374,7 +16778,8 @@ var shapeBar = {
|
|
|
16374
16778
|
$el.bar = $el.main.select(".".concat($COMMON.chart))
|
|
16375
16779
|
// should positioned at the beginning of the shape node to not overlap others
|
|
16376
16780
|
.insert("g", ":first-child")
|
|
16377
|
-
.attr("class", $BAR.chartBars)
|
|
16781
|
+
.attr("class", $BAR.chartBars)
|
|
16782
|
+
.call(this.setCssRule(false, ".".concat($BAR.chartBars), ["pointer-events:none"]));
|
|
16378
16783
|
// set clip-path attribute when condition meet
|
|
16379
16784
|
// https://github.com/naver/billboard.js/issues/2421
|
|
16380
16785
|
if (config.clipPath === false && (config.bar_radius || config.bar_radius_ratio)) {
|
|
@@ -16400,11 +16805,12 @@ var shapeBar = {
|
|
|
16400
16805
|
var mainBarEnter = mainBarUpdate.enter().append("g")
|
|
16401
16806
|
.attr("class", classChartBar)
|
|
16402
16807
|
.style("opacity", "0")
|
|
16403
|
-
.style("pointer-events", "none");
|
|
16808
|
+
.style("pointer-events", $$.getStylePropValue("none"));
|
|
16404
16809
|
// Bars for each data
|
|
16405
16810
|
mainBarEnter.append("g")
|
|
16406
16811
|
.attr("class", classBars)
|
|
16407
|
-
.style("cursor", function (d) { var _a; return (((_a = isSelectable === null || isSelectable === void 0 ? void 0 : isSelectable.bind) === null || _a === void 0 ? void 0 : _a.call(isSelectable, $$.api)(d)) ? "pointer" : null); })
|
|
16812
|
+
.style("cursor", function (d) { var _a; return (((_a = isSelectable === null || isSelectable === void 0 ? void 0 : isSelectable.bind) === null || _a === void 0 ? void 0 : _a.call(isSelectable, $$.api)(d)) ? "pointer" : null); })
|
|
16813
|
+
.call($$.setCssRule(true, " .".concat($BAR.bar), ["fill"], $$.color));
|
|
16408
16814
|
},
|
|
16409
16815
|
/**
|
|
16410
16816
|
* Generate/Update elements
|
|
@@ -16427,7 +16833,7 @@ var shapeBar = {
|
|
|
16427
16833
|
.remove();
|
|
16428
16834
|
$root.bar = bar.enter().append("path")
|
|
16429
16835
|
.attr("class", classBar)
|
|
16430
|
-
.style("fill", $$.color)
|
|
16836
|
+
.style("fill", $$.getStylePropValue($$.color))
|
|
16431
16837
|
.merge(bar)
|
|
16432
16838
|
.style("opacity", initialOpacity);
|
|
16433
16839
|
},
|
|
@@ -16445,7 +16851,7 @@ var shapeBar = {
|
|
|
16445
16851
|
return [
|
|
16446
16852
|
$$.$T(bar, withTransition, getRandom())
|
|
16447
16853
|
.attr("d", function (d) { return (isNumber(d.value) || $$.isBarRangeType(d)) && drawFn(d); })
|
|
16448
|
-
.style("fill",
|
|
16854
|
+
.style("fill", $$.getStylePropValue($$.color))
|
|
16449
16855
|
.style("opacity", null)
|
|
16450
16856
|
];
|
|
16451
16857
|
},
|
|
@@ -16489,9 +16895,9 @@ var shapeBar = {
|
|
|
16489
16895
|
var pathRadius = ["", ""];
|
|
16490
16896
|
var radius = 0;
|
|
16491
16897
|
var isGrouped = $$.isGrouped(d.id);
|
|
16492
|
-
|
|
16493
|
-
var isRadiusData =
|
|
16494
|
-
if (
|
|
16898
|
+
// const hasRadius = d.value !== 0 && getRadius;
|
|
16899
|
+
var isRadiusData = getRadius && isGrouped ? $$.isStackingRadiusData(d) : false;
|
|
16900
|
+
if (getRadius && (!isGrouped || isRadiusData)) {
|
|
16495
16901
|
var index = isRotated ? indexY : indexX;
|
|
16496
16902
|
var barW = points[2][index] - points[0][index];
|
|
16497
16903
|
radius = getRadius(barW);
|
|
@@ -16515,15 +16921,20 @@ var shapeBar = {
|
|
|
16515
16921
|
*/
|
|
16516
16922
|
isStackingRadiusData: function (d) {
|
|
16517
16923
|
var $$ = this;
|
|
16518
|
-
var config = $$.config, data = $$.data;
|
|
16924
|
+
var $el = $$.$el, config = $$.config, data = $$.data, state = $$.state;
|
|
16519
16925
|
var id = d.id, index = d.index, value = d.value;
|
|
16926
|
+
// when the data is hidden, check if has rounded edges
|
|
16927
|
+
if (state.hiddenTargetIds.indexOf(id) > -1) {
|
|
16928
|
+
var target = $el.bar.filter(function (d) { return d.id === id && d.value === value; });
|
|
16929
|
+
return !target.empty() && /a\d+/i.test(target.attr("d"));
|
|
16930
|
+
}
|
|
16520
16931
|
// Find same grouped ids
|
|
16521
16932
|
var keys = config.data_groups.find(function (v) { return v.indexOf(id) > -1; });
|
|
16522
16933
|
// Get sorted list
|
|
16523
16934
|
var sortedList = $$.orderTargets($$.filterTargetsToShow(data.targets.filter($$.isBarType, $$))).filter(function (v) { return keys.indexOf(v.id) > -1; });
|
|
16524
16935
|
// Get sorted Ids. Filter positive or negative values Ids from given value
|
|
16525
16936
|
var sortedIds = sortedList
|
|
16526
|
-
.map(function (v) { return v.values.filter(function (v2) { return v2.index === index && (value > 0 ? v2.value > 0 : v2.value < 0); })[0]; })
|
|
16937
|
+
.map(function (v) { return v.values.filter(function (v2) { return v2.index === index && (isNumber(value) && value > 0 ? v2.value > 0 : v2.value < 0); })[0]; })
|
|
16527
16938
|
.filter(Boolean)
|
|
16528
16939
|
.map(function (v) { return v.id; });
|
|
16529
16940
|
// If the given id stays in the last position, then radius should be applied.
|
|
@@ -16550,10 +16961,11 @@ var shapeBar = {
|
|
|
16550
16961
|
var y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id));
|
|
16551
16962
|
var offset = barOffset(d, i) || y0; // offset is for stacked bar chart
|
|
16552
16963
|
var width = isNumber(barW) ? barW : barW[d.id] || barW._$width;
|
|
16964
|
+
var value = d.value;
|
|
16553
16965
|
var posX = barX(d);
|
|
16554
16966
|
var posY = barY(d);
|
|
16555
16967
|
// fix posY not to overflow opposite quadrant
|
|
16556
|
-
if (config.axis_rotated && ((
|
|
16968
|
+
if (config.axis_rotated && ((value > 0 && posY < y0) || (value < 0 && y0 < posY))) {
|
|
16557
16969
|
posY = y0;
|
|
16558
16970
|
}
|
|
16559
16971
|
if (!$$.isBarRangeType(d)) {
|
|
@@ -16955,7 +17367,8 @@ var shapeLine = {
|
|
|
16955
17367
|
initLine: function () {
|
|
16956
17368
|
var $el = this.$el;
|
|
16957
17369
|
$el.line = $el.main.select(".".concat($COMMON.chart)).append("g")
|
|
16958
|
-
.attr("class", $LINE.chartLines)
|
|
17370
|
+
.attr("class", $LINE.chartLines)
|
|
17371
|
+
.call(this.setCssRule(false, ".".concat($LINE.chartLines), ["pointer-events:none"]));
|
|
16959
17372
|
},
|
|
16960
17373
|
updateTargetsForLine: function (t) {
|
|
16961
17374
|
var $$ = this;
|
|
@@ -16974,7 +17387,7 @@ var shapeLine = {
|
|
|
16974
17387
|
var mainLineEnter = mainLineUpdate.enter().append("g")
|
|
16975
17388
|
.attr("class", classChartLine)
|
|
16976
17389
|
.style("opacity", "0")
|
|
16977
|
-
.style("pointer-events", "none");
|
|
17390
|
+
.style("pointer-events", $$.getStylePropValue("none"));
|
|
16978
17391
|
// Lines for each data
|
|
16979
17392
|
mainLineEnter.append("g")
|
|
16980
17393
|
.attr("class", classLines);
|
|
@@ -17277,7 +17690,10 @@ var shapePoint = {
|
|
|
17277
17690
|
.attr("class", function (d) { return $$.generateClass($SELECT.selectedCircles, d.id); });
|
|
17278
17691
|
enterNode.append("g")
|
|
17279
17692
|
.attr("class", classCircles)
|
|
17280
|
-
.
|
|
17693
|
+
.call(function (selection) {
|
|
17694
|
+
$$.setCssRule(true, ".".concat($CIRCLE.circles), ["cursor:pointer"], isSelectable)(selection);
|
|
17695
|
+
$$.setCssRule(true, " .".concat($CIRCLE.circle), ["fill", "stroke"], $$.color)(selection);
|
|
17696
|
+
})
|
|
17281
17697
|
.style("opacity", function () {
|
|
17282
17698
|
var parent = select(this.parentNode);
|
|
17283
17699
|
// if the parent node is .bb-chart-circles (bubble, scatter), initialize <g bb-circles> with opacity "0"
|
|
@@ -17307,9 +17723,9 @@ var shapePoint = {
|
|
|
17307
17723
|
circles.exit().remove();
|
|
17308
17724
|
circles.enter()
|
|
17309
17725
|
.filter(Boolean)
|
|
17310
|
-
.append($$.point("create", this, $$.pointR.bind($$), $$.color));
|
|
17726
|
+
.append($$.point("create", this, $$.pointR.bind($$), $$.getStylePropValue($$.color)));
|
|
17311
17727
|
$root.circle = $root.main.selectAll(".".concat($CIRCLE.circles, " .").concat($CIRCLE.circle))
|
|
17312
|
-
.style("stroke", $$.color)
|
|
17728
|
+
.style("stroke", $$.getStylePropValue($$.color))
|
|
17313
17729
|
.style("opacity", $$.initialOpacityForCircle.bind($$));
|
|
17314
17730
|
}
|
|
17315
17731
|
},
|
|
@@ -17322,7 +17738,7 @@ var shapePoint = {
|
|
|
17322
17738
|
if (!$$.config.point_show) {
|
|
17323
17739
|
return [];
|
|
17324
17740
|
}
|
|
17325
|
-
var fn = $$.point("update", $$, cx, cy, $$.color, withTransition, flow, selectedCircles);
|
|
17741
|
+
var fn = $$.point("update", $$, cx, cy, $$.getStylePropValue($$.color), withTransition, flow, selectedCircles);
|
|
17326
17742
|
var posAttr = $$.isCirclePoint() ? "c" : "";
|
|
17327
17743
|
var t = getRandom();
|
|
17328
17744
|
var opacityStyleFn = $$.opacityForCircle.bind($$);
|
|
@@ -17353,7 +17769,7 @@ var shapePoint = {
|
|
|
17353
17769
|
var cx = (hasRadar ? $$.radarCircleX : $$.circleX).bind($$);
|
|
17354
17770
|
var cy = (hasRadar ? $$.radarCircleY : $$.circleY).bind($$);
|
|
17355
17771
|
var withTransition = toggling || isUndefined(d);
|
|
17356
|
-
var fn_1 = $$.point("update", $$, cx, cy, $$.color, resizing ? false : withTransition);
|
|
17772
|
+
var fn_1 = $$.point("update", $$, cx, cy, $$.getStylePropValue($$.color), resizing ? false : withTransition);
|
|
17357
17773
|
if (d) {
|
|
17358
17774
|
circle = circle
|
|
17359
17775
|
.filter(function (t) {
|
|
@@ -17438,8 +17854,10 @@ var shapePoint = {
|
|
|
17438
17854
|
})
|
|
17439
17855
|
.classed($COMMON.EXPANDED, false);
|
|
17440
17856
|
circles.attr("r", r);
|
|
17441
|
-
!$$.isCirclePoint()
|
|
17442
|
-
|
|
17857
|
+
if (!$$.isCirclePoint()) {
|
|
17858
|
+
var scale = r(circles) / $$.config.point_r;
|
|
17859
|
+
circles.attr("transform", scale !== 1 ? "scale(".concat(scale, ")") : null);
|
|
17860
|
+
}
|
|
17443
17861
|
},
|
|
17444
17862
|
pointR: function (d) {
|
|
17445
17863
|
var $$ = this;
|
|
@@ -17593,7 +18011,7 @@ var shapePoint = {
|
|
|
17593
18011
|
};
|
|
17594
18012
|
},
|
|
17595
18013
|
custom: {
|
|
17596
|
-
create: function (element, id,
|
|
18014
|
+
create: function (element, id, fillStyleFn) {
|
|
17597
18015
|
return element.append("use")
|
|
17598
18016
|
.attr("xlink:href", "#".concat(id))
|
|
17599
18017
|
.attr("class", this.updatePointClass.bind(this))
|
|
@@ -17721,8 +18139,9 @@ var shapePolar = {
|
|
|
17721
18139
|
* @private
|
|
17722
18140
|
*/
|
|
17723
18141
|
getPolarOuterRadius: function (d, outerRadius) {
|
|
18142
|
+
var _a;
|
|
17724
18143
|
var dataMax = getDataMax(this);
|
|
17725
|
-
return ((d === null || d === void 0 ? void 0 : d.data.values[0].value) / dataMax) * outerRadius;
|
|
18144
|
+
return (((_a = d === null || d === void 0 ? void 0 : d.data.values[0].value) !== null && _a !== void 0 ? _a : 0) / dataMax) * outerRadius;
|
|
17726
18145
|
},
|
|
17727
18146
|
/**
|
|
17728
18147
|
* Update polar based on given data array
|
|
@@ -18212,7 +18631,9 @@ var optArea = {
|
|
|
18212
18631
|
* @memberof Options
|
|
18213
18632
|
* @type {object}
|
|
18214
18633
|
* @property {object} area Area object
|
|
18215
|
-
* @property {boolean} [area.above=false] Set background area above the data chart line.
|
|
18634
|
+
* @property {boolean} [area.above=false] Set background area `above` the data chart line.
|
|
18635
|
+
* @property {boolean} [area.below=false] Set background area `below` the data chart line.
|
|
18636
|
+
* - **NOTE**: Can't be used along with `above` option. When above & below options are set to true, `above` will be prioritized.
|
|
18216
18637
|
* @property {boolean} [area.front=true] Set area node to be positioned over line node.
|
|
18217
18638
|
* @property {boolean|object} [area.linearGradient=false] Set the linear gradient on area.<br><br>
|
|
18218
18639
|
* Or customize by giving below object value:
|
|
@@ -18223,10 +18644,12 @@ var optArea = {
|
|
|
18223
18644
|
* @see [MDN's <linearGradient>](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/linearGradient), [<stop>](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/stop)
|
|
18224
18645
|
* @see [Demo](https://naver.github.io/billboard.js/demo/#Chart.AreaChart)
|
|
18225
18646
|
* @see [Demo: above](https://naver.github.io/billboard.js/demo/#AreaChartOptions.Above)
|
|
18647
|
+
* @see [Demo: below](https://naver.github.io/billboard.js/demo/#AreaChartOptions.Below)
|
|
18226
18648
|
* @see [Demo: linearGradient](https://naver.github.io/billboard.js/demo/#AreaChartOptions.LinearGradient)
|
|
18227
18649
|
* @example
|
|
18228
18650
|
* area: {
|
|
18229
18651
|
* above: true,
|
|
18652
|
+
* below: false,
|
|
18230
18653
|
* zerobased: false,
|
|
18231
18654
|
*
|
|
18232
18655
|
* // <g class='bb-areas'> will be positioned behind the line <g class='bb-lines'> in stacking order
|
|
@@ -18258,6 +18681,7 @@ var optArea = {
|
|
|
18258
18681
|
* }
|
|
18259
18682
|
*/
|
|
18260
18683
|
area_above: false,
|
|
18684
|
+
area_below: false,
|
|
18261
18685
|
area_front: true,
|
|
18262
18686
|
area_linearGradient: false,
|
|
18263
18687
|
area_zerobased: true
|
|
@@ -20175,18 +20599,28 @@ var zoom = {
|
|
|
20175
20599
|
/**
|
|
20176
20600
|
* Update scale according zoom transform value
|
|
20177
20601
|
* @param {object} transform transform object
|
|
20602
|
+
* @param {boolean} correctTransform if the d3 transform should be updated after rescaling
|
|
20178
20603
|
* @private
|
|
20179
20604
|
*/
|
|
20180
20605
|
// @ts-ignore
|
|
20181
|
-
zoom.updateTransformScale = function (transform) {
|
|
20606
|
+
zoom.updateTransformScale = function (transform, correctTransform) {
|
|
20182
20607
|
var _a;
|
|
20608
|
+
var isRotated = config.axis_rotated;
|
|
20183
20609
|
// in case of resize, update range of orgXScale
|
|
20184
20610
|
(_a = org.xScale) === null || _a === void 0 ? void 0 : _a.range(scale.x.range());
|
|
20185
20611
|
// rescale from the original scale
|
|
20186
|
-
var newScale = transform[
|
|
20612
|
+
var newScale = transform[isRotated ? "rescaleY" : "rescaleX"](org.xScale || scale.x);
|
|
20187
20613
|
var domain = $$.trimXDomain(newScale.domain());
|
|
20188
20614
|
var rescale = config.zoom_rescale;
|
|
20189
20615
|
newScale.domain(domain, org.xDomain);
|
|
20616
|
+
// prevent chart from panning off the edge and feeling "stuck"
|
|
20617
|
+
// https://github.com/naver/billboard.js/issues/2588
|
|
20618
|
+
if (correctTransform) {
|
|
20619
|
+
var t = newScale(scale.x.domain()[0]);
|
|
20620
|
+
var tX = isRotated ? transform.x : t;
|
|
20621
|
+
var tY = isRotated ? t : transform.y;
|
|
20622
|
+
$$.$el.eventRect.property("__zoom", zoomIdentity.translate(tX, tY).scale(transform.k));
|
|
20623
|
+
}
|
|
20190
20624
|
if (!$$.state.xTickOffset) {
|
|
20191
20625
|
$$.state.xTickOffset = $$.axis.x.tickOffset();
|
|
20192
20626
|
}
|
|
@@ -20252,7 +20686,7 @@ var zoom = {
|
|
|
20252
20686
|
if (!isMousemove && isZoomOut && scale.x.domain().every(function (v, i) { return v !== org.xDomain[i]; })) {
|
|
20253
20687
|
scale.x.domain(org.xDomain);
|
|
20254
20688
|
}
|
|
20255
|
-
$$.zoom.updateTransformScale(transform);
|
|
20689
|
+
$$.zoom.updateTransformScale(transform, config.zoom_type === "wheel" && sourceEvent);
|
|
20256
20690
|
// do zoom transiton when:
|
|
20257
20691
|
// - zoom type 'drag'
|
|
20258
20692
|
// - when .unzoom() is called (event.transform === d3ZoomIdentity)
|
|
@@ -20738,7 +21172,7 @@ var zoomModule = function () {
|
|
|
20738
21172
|
var defaults = {};
|
|
20739
21173
|
/**
|
|
20740
21174
|
* @namespace bb
|
|
20741
|
-
* @version 3.
|
|
21175
|
+
* @version 3.5.0
|
|
20742
21176
|
*/
|
|
20743
21177
|
var bb = {
|
|
20744
21178
|
/**
|
|
@@ -20748,7 +21182,7 @@ var bb = {
|
|
|
20748
21182
|
* bb.version; // "1.0.0"
|
|
20749
21183
|
* @memberof bb
|
|
20750
21184
|
*/
|
|
20751
|
-
version: "3.
|
|
21185
|
+
version: "3.5.0",
|
|
20752
21186
|
/**
|
|
20753
21187
|
* Generate chart
|
|
20754
21188
|
* - **NOTE:** Bear in mind for the possiblity of ***throwing an error***, during the generation when:
|