billboard.js 3.5.0-next.1 → 3.5.0-next.2

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.
Files changed (57) hide show
  1. package/README.md +4 -1
  2. package/dist/billboard.css +1 -1
  3. package/dist/billboard.js +730 -453
  4. package/dist/billboard.min.css +1 -1
  5. package/dist/billboard.min.js +2 -2
  6. package/dist/billboard.pkgd.js +1868 -1297
  7. package/dist/billboard.pkgd.min.js +3 -3
  8. package/dist/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  9. package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
  10. package/dist/plugin/billboardjs-plugin-sparkline.js +141 -27
  11. package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
  12. package/dist/plugin/billboardjs-plugin-stanford.js +141 -27
  13. package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
  14. package/dist/plugin/billboardjs-plugin-tableview.js +141 -27
  15. package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
  16. package/dist/plugin/billboardjs-plugin-textoverlap.js +141 -27
  17. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
  18. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.js +1140 -846
  19. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.js +1280 -872
  20. package/dist/plugin/pkgd/billboardjs-plugin-stanford.js +1281 -873
  21. package/dist/plugin/pkgd/billboardjs-plugin-tableview.js +1282 -874
  22. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.js +1283 -875
  23. package/dist/theme/datalab.css +1 -1
  24. package/dist/theme/datalab.min.css +1 -1
  25. package/dist/theme/graph.css +1 -1
  26. package/dist/theme/graph.min.css +1 -1
  27. package/dist/theme/insight.css +1 -1
  28. package/dist/theme/insight.min.css +1 -1
  29. package/dist-esm/billboard.js +591 -348
  30. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  31. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +4 -3
  32. package/dist-esm/plugin/billboardjs-plugin-stanford.js +4 -3
  33. package/dist-esm/plugin/billboardjs-plugin-tableview.js +4 -3
  34. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +4 -3
  35. package/package.json +14 -14
  36. package/src/Chart/api/chart.ts +4 -1
  37. package/src/Chart/api/flow.ts +125 -115
  38. package/src/ChartInternal/ChartInternal.ts +47 -17
  39. package/src/ChartInternal/data/IData.ts +2 -2
  40. package/src/ChartInternal/data/convert.helper.ts +226 -0
  41. package/src/ChartInternal/data/convert.ts +43 -210
  42. package/src/ChartInternal/data/load.ts +5 -4
  43. package/src/ChartInternal/internals/color.ts +56 -34
  44. package/src/ChartInternal/internals/text.ts +4 -3
  45. package/src/ChartInternal/shape/area.ts +14 -7
  46. package/src/ChartInternal/shape/bar.ts +8 -6
  47. package/src/ChartInternal/shape/point.ts +12 -8
  48. package/src/ChartInternal/shape/polar.ts +1 -1
  49. package/src/Plugin/textoverlap/index.ts +4 -1
  50. package/src/config/Options/Options.ts +2 -0
  51. package/src/config/Options/common/boost.ts +31 -0
  52. package/src/config/Options/shape/area.ts +6 -1
  53. package/src/config/Store/State.ts +3 -0
  54. package/src/module/browser.ts +2 -1
  55. package/src/module/generator.ts +7 -12
  56. package/src/module/util.ts +113 -0
  57. package/types/options.d.ts +24 -0
package/dist/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.5.0-next.1
8
+ * @version 3.5.0-next.2
9
9
  */
10
10
  (function webpackUniversalModuleDefinition(root, factory) {
11
11
  if(typeof exports === 'object' && typeof module === 'object')
@@ -241,12 +241,13 @@ win.requestIdleCallback = win.requestIdleCallback || function (cb) {
241
241
  _newArrowCheck(this, _this);
242
242
 
243
243
  return setTimeout(cb, 1);
244
- }.bind(undefined);
244
+ }.bind(undefined); // win.cancelIdleCallback = win.cancelIdleCallback || (id => clearTimeout(id));
245
+
245
246
 
246
- win.cancelIdleCallback = win.cancelIdleCallback || function (id) {
247
+ win.requestAnimationFrame = win.requestAnimationFrame || function (cb) {
247
248
  _newArrowCheck(this, _this);
248
249
 
249
- return clearTimeout(id);
250
+ return setTimeout(cb, 1);
250
251
  }.bind(undefined);
251
252
 
252
253
  var browser_doc = win == null ? void 0 : win.document;
@@ -888,6 +889,29 @@ var toArray = function (v) {
888
889
 
889
890
  return [].slice.call(v);
890
891
  }.bind(undefined);
892
+ /**
893
+ * Add CSS rules
894
+ * @param {object} style Style object
895
+ * @param {string} selector Selector string
896
+ * @param {Array} prop Prps arrary
897
+ * @returns {number} Newely added rule index
898
+ * @private
899
+ */
900
+
901
+
902
+ function addCssRules(style, selector, prop) {
903
+ var _this9 = this,
904
+ rootSelctor = style.rootSelctor,
905
+ sheet = style.sheet,
906
+ getSelector = function (s) {
907
+ _newArrowCheck(this, _this9);
908
+
909
+ return s.replace(/\s?(bb-)/g, ".$1").replace(/\.+/g, ".");
910
+ }.bind(this),
911
+ rule = rootSelctor + " " + getSelector(selector) + " {" + prop.join(";") + "}";
912
+
913
+ return sheet[sheet.insertRule ? "insertRule" : "addRule"](rule, sheet.cssRules.length);
914
+ }
891
915
  /**
892
916
  * Get css rules for specified stylesheets
893
917
  * @param {Array} styleSheets The stylesheets to get the rules from
@@ -897,11 +921,11 @@ var toArray = function (v) {
897
921
 
898
922
 
899
923
  function getCssRules(styleSheets) {
900
- var _this9 = this,
924
+ var _this10 = this,
901
925
  rules = [];
902
926
 
903
927
  styleSheets.forEach(function (sheet) {
904
- _newArrowCheck(this, _this9);
928
+ _newArrowCheck(this, _this10);
905
929
 
906
930
  try {
907
931
  if (sheet.cssRules && sheet.cssRules.length) {
@@ -942,16 +966,16 @@ function getTranslation(node) {
942
966
 
943
967
 
944
968
  function getUnique(data) {
945
- var _this10 = this,
969
+ var _this11 = this,
946
970
  isDate = data[0] instanceof Date,
947
971
  d = (isDate ? data.map(Number) : data).filter(function (v, i, self) {
948
- _newArrowCheck(this, _this10);
972
+ _newArrowCheck(this, _this11);
949
973
 
950
974
  return self.indexOf(v) === i;
951
975
  }.bind(this));
952
976
 
953
977
  return isDate ? d.map(function (v) {
954
- _newArrowCheck(this, _this10);
978
+ _newArrowCheck(this, _this11);
955
979
 
956
980
  return new Date(v);
957
981
  }.bind(this)) : d;
@@ -965,10 +989,10 @@ function getUnique(data) {
965
989
 
966
990
 
967
991
  function mergeArray(arr) {
968
- var _this11 = this;
992
+ var _this12 = this;
969
993
 
970
994
  return arr && arr.length ? arr.reduce(function (p, c) {
971
- _newArrowCheck(this, _this11);
995
+ _newArrowCheck(this, _this12);
972
996
 
973
997
  return p.concat(c);
974
998
  }.bind(this)) : [];
@@ -983,7 +1007,7 @@ function mergeArray(arr) {
983
1007
 
984
1008
 
985
1009
  function mergeObj(target) {
986
- for (var _this12 = this, _len4 = arguments.length, objectN = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
1010
+ for (var _this13 = this, _len4 = arguments.length, objectN = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
987
1011
  objectN[_key4 - 1] = arguments[_key4];
988
1012
  }
989
1013
 
@@ -995,7 +1019,7 @@ function mergeObj(target) {
995
1019
 
996
1020
  if (isObject(target) && isObject(source)) {
997
1021
  Object.keys(source).forEach(function (key) {
998
- _newArrowCheck(this, _this12);
1022
+ _newArrowCheck(this, _this13);
999
1023
 
1000
1024
  var value = source[key];
1001
1025
 
@@ -1020,7 +1044,7 @@ function mergeObj(target) {
1020
1044
 
1021
1045
 
1022
1046
  function sortValue(data, isAsc) {
1023
- var _this13 = this;
1047
+ var _this14 = this;
1024
1048
 
1025
1049
  if (isAsc === void 0) {
1026
1050
  isAsc = !0;
@@ -1030,24 +1054,24 @@ function sortValue(data, isAsc) {
1030
1054
 
1031
1055
  if (data[0] instanceof Date) {
1032
1056
  fn = isAsc ? function (a, b) {
1033
- _newArrowCheck(this, _this13);
1057
+ _newArrowCheck(this, _this14);
1034
1058
 
1035
1059
  return a - b;
1036
1060
  }.bind(this) : function (a, b) {
1037
- _newArrowCheck(this, _this13);
1061
+ _newArrowCheck(this, _this14);
1038
1062
 
1039
1063
  return b - a;
1040
1064
  }.bind(this);
1041
1065
  } else {
1042
1066
  if (isAsc && !data.every(isNaN)) {
1043
1067
  fn = function (a, b) {
1044
- _newArrowCheck(this, _this13);
1068
+ _newArrowCheck(this, _this14);
1045
1069
 
1046
1070
  return a - b;
1047
1071
  }.bind(this);
1048
1072
  } else if (!isAsc) {
1049
1073
  fn = function (a, b) {
1050
- _newArrowCheck(this, _this13);
1074
+ _newArrowCheck(this, _this14);
1051
1075
 
1052
1076
  return a > b && -1 || a < b && 1 || a === b && 0;
1053
1077
  }.bind(this);
@@ -1066,9 +1090,9 @@ function sortValue(data, isAsc) {
1066
1090
 
1067
1091
 
1068
1092
  function getMinMax(type, data) {
1069
- var _this14 = this,
1093
+ var _this15 = this,
1070
1094
  res = data.filter(function (v) {
1071
- _newArrowCheck(this, _this14);
1095
+ _newArrowCheck(this, _this15);
1072
1096
 
1073
1097
  return notEmpty(v);
1074
1098
  }.bind(this));
@@ -1113,12 +1137,12 @@ var getRange = function (start, end, step) {
1113
1137
  }.bind(undefined),
1114
1138
  emulateEvent = {
1115
1139
  mouse: function () {
1116
- var _this15 = this;
1140
+ var _this16 = this;
1117
1141
 
1118
1142
  _newArrowCheck(this, util_this);
1119
1143
 
1120
1144
  var getParams = function () {
1121
- _newArrowCheck(this, _this15);
1145
+ _newArrowCheck(this, _this16);
1122
1146
 
1123
1147
  return {
1124
1148
  bubbles: !1,
@@ -1138,7 +1162,7 @@ var getRange = function (start, end, step) {
1138
1162
  params = getParams();
1139
1163
  }
1140
1164
 
1141
- _newArrowCheck(this, _this15);
1165
+ _newArrowCheck(this, _this16);
1142
1166
 
1143
1167
  el.dispatchEvent(new MouseEvent(eventType, params));
1144
1168
  }.bind(this);
@@ -1149,7 +1173,7 @@ var getRange = function (start, end, step) {
1149
1173
  params = getParams();
1150
1174
  }
1151
1175
 
1152
- _newArrowCheck(this, _this15);
1176
+ _newArrowCheck(this, _this16);
1153
1177
 
1154
1178
  var mouseEvent = browser_doc.createEvent("MouseEvent"); // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/initMouseEvent
1155
1179
 
@@ -1250,7 +1274,7 @@ function isTabVisible() {
1250
1274
 
1251
1275
 
1252
1276
  function convertInputType(mouse, touch) {
1253
- var _this16 = this,
1277
+ var _this17 = this,
1254
1278
  DocumentTouch = win.DocumentTouch,
1255
1279
  matchMedia = win.matchMedia,
1256
1280
  navigator = win.navigator,
@@ -1279,13 +1303,103 @@ function convertInputType(mouse, touch) {
1279
1303
 
1280
1304
 
1281
1305
  var hasMouse = mouse && ["any-hover:hover", "any-pointer:fine"].some(function (v) {
1282
- _newArrowCheck(this, _this16);
1306
+ _newArrowCheck(this, _this17);
1283
1307
 
1284
1308
  return matchMedia == null ? void 0 : matchMedia("(" + v + ")").matches;
1285
1309
  }.bind(this)); // fallback to 'mouse' if no input type is detected.
1286
1310
 
1287
1311
  return hasMouse && "mouse" || hasTouch && "touch" || "mouse";
1288
1312
  }
1313
+ /**
1314
+ * Create and run on Web Worker
1315
+ * @param {boolean} useWorker Use Web Worker
1316
+ * @param {Function} fn Function to be executed in worker
1317
+ * @param {Function} callback Callback function to receive result from worker
1318
+ * @param {Array} depsFn Dependency functions to run given function(fn).
1319
+ * @returns {object}
1320
+ * @example
1321
+ * const worker = runWorker(function(arg) {
1322
+ * // do some tasks...
1323
+ * console.log("param:", A(arg));
1324
+ *
1325
+ * return 1234;
1326
+ * }, function(data) {
1327
+ * // callback after worker is done
1328
+ * console.log("result:", data);
1329
+ * },
1330
+ * [function A(){}]
1331
+ * );
1332
+ *
1333
+ * worker(11111);
1334
+ * @private
1335
+ */
1336
+
1337
+
1338
+ function runWorker(useWorker, fn, callback, depsFn) {
1339
+ if (useWorker === void 0) {
1340
+ useWorker = !0;
1341
+ }
1342
+
1343
+ var runFn;
1344
+
1345
+ if (win.Worker && useWorker) {
1346
+ var _depsFn$map$join,
1347
+ blob = new Blob([((_depsFn$map$join = depsFn == null ? void 0 : depsFn.map(String).join(";")) != null ? _depsFn$map$join : "") + "\n\n\t\t\tself.onmessage=function({data}) {\n\t\t\t\tconst result = (" + fn.toString() + ").apply(null, data);\n\t\t\t\tself.postMessage(result);\n\t\t\t};"], {
1348
+ type: "text/javascript"
1349
+ }),
1350
+ worker = new Worker(URL.createObjectURL(blob));
1351
+
1352
+ runFn = function () {
1353
+ for (var _len5 = arguments.length, args = Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
1354
+ args[_key5] = arguments[_key5];
1355
+ }
1356
+
1357
+ // trigger worker
1358
+ worker.postMessage(args); // listen worker
1359
+
1360
+ worker.onmessage = function (e) {
1361
+ return callback(e.data);
1362
+ }; // handle error
1363
+
1364
+
1365
+ worker.onerror = function (e) {
1366
+ console.error(e);
1367
+ }; // return new Promise((resolve, reject) => {
1368
+ // worker.onmessage = ({data}) => resolve(data);
1369
+ // worker.onerror = reject;
1370
+ // });
1371
+
1372
+ };
1373
+ } else {
1374
+ runFn = function () {
1375
+ var res = fn.apply(void 0, arguments);
1376
+ callback(res);
1377
+ };
1378
+ }
1379
+
1380
+ return runFn;
1381
+ }
1382
+ /**
1383
+ * Run function until given condition function return true
1384
+ * @param {Function} fn Function to be executed when condition is true
1385
+ * @param {Function} conditionFn Condition function to check if condition is true
1386
+ * @private
1387
+ */
1388
+
1389
+
1390
+ function runUntil(fn, conditionFn) {
1391
+ var _this18 = this;
1392
+
1393
+ if (conditionFn() === !1) {
1394
+ win.requestAnimationFrame(function () {
1395
+ _newArrowCheck(this, _this18);
1396
+
1397
+ return runUntil(fn, conditionFn);
1398
+ }.bind(this));
1399
+ } else {
1400
+ fn();
1401
+ }
1402
+ }
1289
1403
  ;// CONCATENATED MODULE: ./src/module/error.ts
1290
1404
 
1291
1405
 
@@ -1629,6 +1743,8 @@ var State = function () {
1629
1743
  xAxisHeight: 0,
1630
1744
  hasAxis: !1,
1631
1745
  hasRadar: !1,
1746
+ // for data CSS rule index (used when boost.useCssRule is true)
1747
+ colorRule: {},
1632
1748
  current: {
1633
1749
  // chart whole dimension
1634
1750
  width: 0,
@@ -2182,6 +2298,39 @@ var Store = /*#__PURE__*/function () {
2182
2298
  */
2183
2299
  regions: []
2184
2300
  });
2301
+ ;// CONCATENATED MODULE: ./src/config/Options/common/boost.ts
2302
+ /**
2303
+ * Copyright (c) 2017 ~ present NAVER Corp.
2304
+ * billboard.js project is licensed under the MIT license
2305
+ */
2306
+
2307
+ /**
2308
+ * boost config options
2309
+ */
2310
+ /* harmony default export */ var boost = ({
2311
+ /**
2312
+ * Set boost options
2313
+ * @name boost
2314
+ * @memberof Options
2315
+ * @type {object}
2316
+ * @property {object} boost boost object
2317
+ * @property {boolean} [boost.useCssRule=false] Avoid setting inline styles for each shape elements.
2318
+ * - **NOTE:**
2319
+ * - Will append &lt;style> to the head tag and will add shpes' CSS rules dynamically.
2320
+ * - For now, covers colors related properties (fill, stroke, etc.) only.
2321
+ * @property {boolean} [boost.useWorker=false] Use Web Worker as possible for processing.
2322
+ * - **NOTE:**
2323
+ * - For now, only applies for data conversion at the initial time.
2324
+ * - As of Web Worker's async nature, handling chart instance synchrously is not recommended.
2325
+ * @example
2326
+ * boost: {
2327
+ * useCssRule: true,
2328
+ * useWorker: false
2329
+ * }
2330
+ */
2331
+ boost_useCssRule: !1,
2332
+ boost_useWorker: !1
2333
+ });
2185
2334
  ;// CONCATENATED MODULE: ./src/config/Options/data/data.ts
2186
2335
 
2187
2336
 
@@ -3589,6 +3738,7 @@ function Options_objectSpread(target) { for (var i = 1, source; i < arguments.le
3589
3738
 
3590
3739
 
3591
3740
 
3741
+
3592
3742
  /**
3593
3743
  * Class to set options on generating chart.
3594
3744
  * - It's instantiated internally, not exposed for public.
@@ -3608,7 +3758,7 @@ var Options = /*#__PURE__*/function () {
3608
3758
  };
3609
3759
 
3610
3760
  function Options() {
3611
- return deepClone(main, data, color, interaction, legend, title, tooltip, Options.data);
3761
+ return deepClone(main, boost, data, color, interaction, legend, title, tooltip, Options.data);
3612
3762
  }
3613
3763
 
3614
3764
  return Options;
@@ -3848,12 +3998,13 @@ function generateResize(option) {
3848
3998
  function generateWait() {
3849
3999
  var transitionsToWait = [],
3850
4000
  f = function (selection, callback) {
3851
- var timer;
4001
+ var _this5 = this;
4002
+
3852
4003
  /**
3853
4004
  * Check if transition is complete
4005
+ * @returns {boolean} Whether transition is complete
3854
4006
  * @private
3855
4007
  */
3856
-
3857
4008
  function loop() {
3858
4009
  var done = 0;
3859
4010
 
@@ -3876,16 +4027,14 @@ function generateWait() {
3876
4027
  }
3877
4028
  }
3878
4029
 
3879
- timer && generator_clearTimeout(timer);
3880
-
3881
- if (done === transitionsToWait.length) {
3882
- callback == null ? void 0 : callback();
3883
- } else {
3884
- timer = generator_setTimeout(loop, 50);
3885
- }
4030
+ return done === transitionsToWait.length;
3886
4031
  }
3887
4032
 
3888
- loop();
4033
+ runUntil(function () {
4034
+ _newArrowCheck(this, _this5);
4035
+
4036
+ callback == null ? void 0 : callback();
4037
+ }.bind(this), loop);
3889
4038
  }; // 'f' is called as selection.call(f, ...);
3890
4039
 
3891
4040
 
@@ -3897,7 +4046,7 @@ function generateWait() {
3897
4046
  }
3898
4047
  // EXTERNAL MODULE: external {"commonjs":"d3-dsv","commonjs2":"d3-dsv","amd":"d3-dsv","root":"d3"}
3899
4048
  var external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_ = __webpack_require__(5);
3900
- ;// CONCATENATED MODULE: ./src/ChartInternal/data/convert.ts
4049
+ ;// CONCATENATED MODULE: ./src/ChartInternal/data/convert.helper.ts
3901
4050
 
3902
4051
 
3903
4052
  /**
@@ -3905,260 +4054,287 @@ var external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_ = __webpack_re
3905
4054
  * billboard.js project is licensed under the MIT license
3906
4055
  */
3907
4056
 
4057
+ /* eslint-disable */
4058
+
4059
+
4060
+ /***** Functions to be executed on Web Worker *****
4061
+ * NOTE: Don't allowed to use
4062
+ * - arrow function syntax
4063
+ * - Utils functions
4064
+ */
3908
4065
 
3909
4066
  /**
3910
- * Data convert
3911
- * @memberof ChartInternal
4067
+ * Convert Columns data
4068
+ * @param {object} columns
4069
+ * @returns {Array}
3912
4070
  * @private
3913
4071
  */
3914
4072
 
3915
- /* harmony default export */ var convert = ({
3916
- /**
3917
- * Convert data according its type
3918
- * @param {object} args data object
3919
- * @param {Function} [callback] callback for url(XHR) type loading
3920
- * @returns {object}
3921
- * @private
3922
- */
3923
- convertData: function convertData(args, callback) {
3924
- var _this = this,
3925
- data;
4073
+ function columns(columns) {
4074
+ var newRows = [];
4075
+ columns.forEach(function (col, i) {
4076
+ var key = col[0];
4077
+ col.forEach(function (v, j) {
4078
+ if (j > 0) {
4079
+ if (typeof newRows[j - 1] === "undefined") {
4080
+ newRows[j - 1] = {};
4081
+ }
3926
4082
 
3927
- if (args.bindto) {
3928
- data = {};
3929
- ["url", "mimeType", "headers", "keys", "json", "keys", "rows", "columns"].forEach(function (v) {
3930
- _newArrowCheck(this, _this);
4083
+ if (typeof v === "undefined") {
4084
+ throw new Error("Source data is missing a component at (" + i + ", " + j + ")!");
4085
+ }
3931
4086
 
3932
- var key = "data_" + v;
4087
+ newRows[j - 1][key] = v;
4088
+ }
4089
+ });
4090
+ });
4091
+ return newRows;
4092
+ }
4093
+ /**
4094
+ * Convert Rows data
4095
+ * @param {object} columns
4096
+ * @returns {Array}
4097
+ * @private
4098
+ */
3933
4099
 
3934
- if (key in args) {
3935
- data[v] = args[key];
4100
+
4101
+ function rows(rows) {
4102
+ var keys = rows[0],
4103
+ newRows = [];
4104
+ rows.forEach(function (row, i) {
4105
+ if (i > 0) {
4106
+ var newRow = {};
4107
+ row.forEach(function (v, j) {
4108
+ if (typeof v === "undefined") {
4109
+ throw new Error("Source data is missing a component at (" + i + ", " + j + ")!");
3936
4110
  }
3937
- }.bind(this));
3938
- } else {
3939
- data = args;
3940
- }
3941
4111
 
3942
- if (data.url && callback) {
3943
- this.convertUrlToData(data.url, data.mimeType, data.headers, data.keys, callback);
3944
- } else if (data.json) {
3945
- data = this.convertJsonToData(data.json, data.keys);
3946
- } else if (data.rows) {
3947
- data = this.convertRowsToData(data.rows);
3948
- } else if (data.columns) {
3949
- data = this.convertColumnsToData(data.columns);
3950
- } else if (args.bindto) {
3951
- throw Error("url or json or rows or columns is required.");
4112
+ newRow[keys[j]] = v;
4113
+ });
4114
+ newRows.push(newRow);
3952
4115
  }
4116
+ });
4117
+ return newRows;
4118
+ }
4119
+ /**
4120
+ * Convert JSON data
4121
+ * @param {object} columns
4122
+ * @returns {Array}
4123
+ * @private
4124
+ */
3953
4125
 
3954
- return isArray(data) && data;
3955
- },
3956
-
3957
- /**
3958
- * Convert URL data
3959
- * @param {string} url Remote URL
3960
- * @param {string} mimeType MIME type string: json | csv | tsv
3961
- * @param {object} headers Header object
3962
- * @param {object} keys Key object
3963
- * @param {Function} done Callback function
3964
- * @private
3965
- */
3966
- convertUrlToData: function convertUrlToData(url, mimeType, headers, keys, done) {
3967
- var _this2 = this;
3968
4126
 
3969
- if (mimeType === void 0) {
3970
- mimeType = "csv";
4127
+ function json(json, keysParam) {
4128
+ var newRows = [],
4129
+ findValueInJson = function (object, path) {
4130
+ if (object[path] !== undefined) {
4131
+ return object[path];
3971
4132
  }
3972
4133
 
3973
- var req = new XMLHttpRequest();
3974
- req.open("GET", url);
4134
+ var convertedPath = path.replace(/\[(\w+)\]/g, ".$1"),
4135
+ pathArray = convertedPath.replace(/^\./, "").split("."),
4136
+ target = object; // convert indexes to properties (replace [] with .)
3975
4137
 
3976
- if (headers) {
3977
- Object.keys(headers).forEach(function (key) {
3978
- _newArrowCheck(this, _this2);
4138
+ pathArray.some(function (k) {
4139
+ return !(target = target && k in target ? target[k] : undefined);
4140
+ });
4141
+ return target;
4142
+ },
4143
+ targetKeys,
4144
+ data;
3979
4145
 
3980
- req.setRequestHeader(key, headers[key]);
3981
- }.bind(this));
4146
+ if (Array.isArray(json)) {
4147
+ if (keysParam.x) {
4148
+ targetKeys = keysParam.value.concat(keysParam.x);
4149
+ } else {
4150
+ targetKeys = keysParam.value;
3982
4151
  }
3983
4152
 
3984
- req.onreadystatechange = function () {
3985
- _newArrowCheck(this, _this2);
4153
+ newRows.push(targetKeys);
4154
+ json.forEach(function (o) {
4155
+ var newRow = targetKeys.map(function (key) {
4156
+ // convert undefined to null because undefined data will be removed in convertDataToTargets()
4157
+ var v = findValueInJson(o, key);
3986
4158
 
3987
- if (req.readyState === 4) {
3988
- if (req.status === 200) {
3989
- var response = req.responseText;
3990
- response && done.call(this, this["convert" + capitalize(mimeType) + "ToData"](mimeType === "json" ? JSON.parse(response) : response, keys));
3991
- } else {
3992
- throw new Error(url + ": Something went wrong loading!");
4159
+ if (typeof v === "undefined") {
4160
+ v = null;
3993
4161
  }
3994
- }
3995
- }.bind(this);
3996
4162
 
3997
- req.send();
3998
- },
4163
+ return v;
4164
+ });
4165
+ newRows.push(newRow);
4166
+ });
4167
+ data = rows(newRows);
4168
+ } else {
4169
+ Object.keys(json).forEach(function (key) {
4170
+ var tmp = json[key].concat();
4171
+ tmp.unshift(key);
4172
+ newRows.push(tmp);
4173
+ });
4174
+ data = columns(newRows);
4175
+ }
3999
4176
 
4000
- /**
4001
- * Convert CSV/TSV data
4002
- * @param {object} parser Parser object
4003
- * @param {object} xsv Data
4004
- * @private
4005
- * @returns {object}
4006
- */
4007
- convertCsvTsvToData: function convertCsvTsvToData(parser, xsv) {
4008
- var _this3 = this,
4009
- rows = parser.rows(xsv),
4010
- d;
4177
+ return data;
4178
+ }
4179
+ /***** Functions can't be executed on Web Worker *****/
4011
4180
 
4012
- if (rows.length === 1) {
4013
- d = [{}];
4014
- rows[0].forEach(function (id) {
4015
- _newArrowCheck(this, _this3);
4181
+ /**
4182
+ * Convert URL data
4183
+ * @param {string} url Remote URL
4184
+ * @param {string} mimeType MIME type string: json | csv | tsv
4185
+ * @param {object} headers Header object
4186
+ * @param {object} keys Key object
4187
+ * @param {Function} done Callback function
4188
+ * @private
4189
+ */
4016
4190
 
4017
- d[0][id] = null;
4018
- }.bind(this));
4019
- } else {
4020
- d = parser.parse(xsv);
4021
- }
4022
4191
 
4023
- return d;
4024
- },
4025
- convertCsvToData: function convertCsvToData(xsv) {
4026
- return this.convertCsvTsvToData({
4027
- rows: external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_.csvParseRows,
4028
- parse: external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_.csvParse
4029
- }, xsv);
4030
- },
4031
- convertTsvToData: function convertTsvToData(tsv) {
4032
- return this.convertCsvTsvToData({
4033
- rows: external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_.tsvParseRows,
4034
- parse: external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_.tsvParse
4035
- }, tsv);
4036
- },
4037
- convertJsonToData: function convertJsonToData(json, keysParam) {
4038
- var _this4 = this,
4039
- config = this.config,
4040
- newRows = [],
4041
- targetKeys,
4042
- data;
4192
+ function url(url, mimeType, headers, keys, done) {
4193
+ if (mimeType === void 0) {
4194
+ mimeType = "csv";
4195
+ }
4043
4196
 
4044
- if (isArray(json)) {
4045
- var keys = keysParam || config.data_keys;
4197
+ var req = new XMLHttpRequest(),
4198
+ converter = {
4199
+ csv: csv,
4200
+ tsv: tsv,
4201
+ json: json
4202
+ };
4203
+ req.open("GET", url);
4204
+
4205
+ if (headers) {
4206
+ Object.keys(headers).forEach(function (key) {
4207
+ req.setRequestHeader(key, headers[key]);
4208
+ });
4209
+ }
4046
4210
 
4047
- if (keys.x) {
4048
- targetKeys = keys.value.concat(keys.x);
4049
- config.data_x = keys.x;
4211
+ req.onreadystatechange = function () {
4212
+ if (req.readyState === 4) {
4213
+ if (req.status === 200) {
4214
+ var response = req.responseText;
4215
+ response && done.call(this, converter[mimeType](mimeType === "json" ? JSON.parse(response) : response, keys));
4050
4216
  } else {
4051
- targetKeys = keys.value;
4217
+ throw new Error(url + ": Something went wrong loading!");
4052
4218
  }
4219
+ }
4220
+ };
4053
4221
 
4054
- newRows.push(targetKeys);
4055
- json.forEach(function (o) {
4056
- var _this5 = this;
4057
-
4058
- _newArrowCheck(this, _this4);
4059
-
4060
- var newRow = targetKeys.map(function (key) {
4061
- _newArrowCheck(this, _this5);
4222
+ req.send();
4223
+ }
4224
+ /**
4225
+ * Convert CSV/TSV data
4226
+ * @param {object} parser Parser object
4227
+ * @param {object} xsv Data
4228
+ * @returns {object}
4229
+ * @private
4230
+ */
4062
4231
 
4063
- // convert undefined to null because undefined data will be removed in convertDataToTargets()
4064
- var v = this.findValueInJson(o, key);
4065
4232
 
4066
- if (isUndefined(v)) {
4067
- v = null;
4068
- }
4069
-
4070
- return v;
4071
- }.bind(this));
4072
- newRows.push(newRow);
4073
- }.bind(this));
4074
- data = this.convertRowsToData(newRows);
4075
- } else {
4076
- Object.keys(json).forEach(function (key) {
4077
- _newArrowCheck(this, _this4);
4233
+ function convertCsvTsvToData(parser, xsv) {
4234
+ var _this = this,
4235
+ rows = parser.rows(xsv),
4236
+ d;
4078
4237
 
4079
- var tmp = json[key].concat();
4080
- tmp.unshift(key);
4081
- newRows.push(tmp);
4082
- }.bind(this));
4083
- data = this.convertColumnsToData(newRows);
4084
- }
4238
+ if (rows.length === 1) {
4239
+ d = [{}];
4240
+ rows[0].forEach(function (id) {
4241
+ _newArrowCheck(this, _this);
4085
4242
 
4086
- return data;
4087
- },
4088
- findValueInJson: function findValueInJson(object, path) {
4089
- var _this6 = this;
4243
+ d[0][id] = null;
4244
+ }.bind(this));
4245
+ } else {
4246
+ d = parser.parse(xsv);
4247
+ }
4090
4248
 
4091
- if (object[path] !== undefined) {
4092
- return object[path];
4093
- }
4249
+ return d;
4250
+ }
4094
4251
 
4095
- var convertedPath = path.replace(/\[(\w+)\]/g, ".$1"),
4096
- pathArray = convertedPath.replace(/^\./, "").split("."),
4097
- target = object; // convert indexes to properties (replace [] with .)
4252
+ function csv(xsv) {
4253
+ return convertCsvTsvToData({
4254
+ rows: external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_.csvParseRows,
4255
+ parse: external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_.csvParse
4256
+ }, xsv);
4257
+ }
4098
4258
 
4099
- pathArray.some(function (k) {
4100
- _newArrowCheck(this, _this6);
4259
+ function tsv(tsv) {
4260
+ return convertCsvTsvToData({
4261
+ rows: external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_.tsvParseRows,
4262
+ parse: external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_.tsvParse
4263
+ }, tsv);
4264
+ }
4265
+ ;// CONCATENATED MODULE: ./src/ChartInternal/data/convert.ts
4101
4266
 
4102
- return !(target = target && k in target ? target[k] : undefined);
4103
- }.bind(this));
4104
- return target;
4105
- },
4106
- convertRowsToData: function convertRowsToData(rows) {
4107
- var _this7 = this,
4108
- keys = rows[0],
4109
- newRows = [];
4110
4267
 
4111
- rows.forEach(function (row, i) {
4112
- var _this8 = this;
4268
+ /**
4269
+ * Copyright (c) 2017 ~ present NAVER Corp.
4270
+ * billboard.js project is licensed under the MIT license
4271
+ */
4113
4272
 
4114
- _newArrowCheck(this, _this7);
4115
4273
 
4116
- if (i > 0) {
4117
- var newRow = {};
4118
- row.forEach(function (v, j) {
4119
- _newArrowCheck(this, _this8);
4120
4274
 
4121
- if (isUndefined(v)) {
4122
- throw new Error("Source data is missing a component at (" + i + ", " + j + ")!");
4123
- }
4275
+ /**
4276
+ * Get data key for JSON
4277
+ * @param {string|object} keysParam Key params
4278
+ * @param {object} config Config object
4279
+ * @returns {string} Data key
4280
+ * @private
4281
+ */
4282
+ function getDataKeyForJson(keysParam, config) {
4283
+ var keys = keysParam || (config == null ? void 0 : config.data_keys);
4124
4284
 
4125
- newRow[keys[j]] = v;
4126
- }.bind(this));
4127
- newRows.push(newRow);
4128
- }
4129
- }.bind(this));
4130
- return newRows;
4131
- },
4132
- convertColumnsToData: function convertColumnsToData(columns) {
4133
- var _this9 = this,
4134
- newRows = [];
4285
+ if (keys != null && keys.x) {
4286
+ config.data_x = keys.x;
4287
+ }
4135
4288
 
4136
- columns.forEach(function (col, i) {
4137
- var _this10 = this;
4289
+ return keys;
4290
+ }
4291
+ /**
4292
+ * Data convert
4293
+ * @memberof ChartInternal
4294
+ * @private
4295
+ */
4138
4296
 
4139
- _newArrowCheck(this, _this9);
4140
4297
 
4141
- var key = col[0];
4142
- col.forEach(function (v, j) {
4143
- _newArrowCheck(this, _this10);
4298
+ /* harmony default export */ var convert = ({
4299
+ /**
4300
+ * Convert data according its type
4301
+ * @param {object} args data object
4302
+ * @param {Function} [callback] callback for url(XHR) type loading
4303
+ * @private
4304
+ */
4305
+ convertData: function convertData(args, callback) {
4306
+ var _this = this,
4307
+ config = this.config,
4308
+ useWorker = config.boost_useWorker,
4309
+ data = args;
4144
4310
 
4145
- if (j > 0) {
4146
- if (isUndefined(newRows[j - 1])) {
4147
- newRows[j - 1] = {};
4148
- }
4311
+ if (args.bindto) {
4312
+ data = {};
4313
+ ["url", "mimeType", "headers", "keys", "json", "keys", "rows", "columns"].forEach(function (v) {
4314
+ _newArrowCheck(this, _this);
4149
4315
 
4150
- if (isUndefined(v)) {
4151
- throw new Error("Source data is missing a component at (" + i + ", " + j + ")!");
4152
- }
4316
+ var key = "data_" + v;
4153
4317
 
4154
- newRows[j - 1][key] = v;
4318
+ if (key in args) {
4319
+ data[v] = args[key];
4155
4320
  }
4156
4321
  }.bind(this));
4157
- }.bind(this));
4158
- return newRows;
4322
+ }
4323
+
4324
+ if (data.url && callback) {
4325
+ url(data.url, data.mimeType, data.headers, getDataKeyForJson(data.keys, config), callback);
4326
+ } else if (data.json) {
4327
+ runWorker(useWorker, json, callback, [columns, rows])(data.json, getDataKeyForJson(data.keys, config));
4328
+ } else if (data.rows) {
4329
+ runWorker(useWorker, rows, callback)(data.rows);
4330
+ } else if (data.columns) {
4331
+ runWorker(useWorker, columns, callback)(data.columns);
4332
+ } else if (args.bindto) {
4333
+ throw Error("url or json or rows or columns is required.");
4334
+ }
4159
4335
  },
4160
4336
  convertDataToTargets: function convertDataToTargets(data, appendXs) {
4161
- var _this11 = this,
4337
+ var _this2 = this,
4162
4338
  $$ = this,
4163
4339
  axis = $$.axis,
4164
4340
  config = $$.config,
@@ -4179,9 +4355,9 @@ var external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_ = __webpack_re
4179
4355
  xsData;
4180
4356
  // save x for update data by load when custom x and bb.x API
4181
4357
  ids.forEach(function (id) {
4182
- var _this12 = this;
4358
+ var _this3 = this;
4183
4359
 
4184
- _newArrowCheck(this, _this11);
4360
+ _newArrowCheck(this, _this2);
4185
4361
 
4186
4362
  var xKey = this.getXKey(id);
4187
4363
 
@@ -4189,11 +4365,11 @@ var external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_ = __webpack_re
4189
4365
  // if included in input data
4190
4366
  if (xs.indexOf(xKey) >= 0) {
4191
4367
  xsData = (appendXs && $$.data.xs[id] || []).concat(data.map(function (d) {
4192
- _newArrowCheck(this, _this12);
4368
+ _newArrowCheck(this, _this3);
4193
4369
 
4194
4370
  return d[xKey];
4195
4371
  }.bind(this)).filter(isValue).map(function (rawX, i) {
4196
- _newArrowCheck(this, _this12);
4372
+ _newArrowCheck(this, _this3);
4197
4373
 
4198
4374
  return $$.generateTargetX(rawX, id, i);
4199
4375
  }.bind(this)));
@@ -4207,7 +4383,7 @@ var external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_ = __webpack_re
4207
4383
 
4208
4384
  } else {
4209
4385
  xsData = data.map(function (d, i) {
4210
- _newArrowCheck(this, _this12);
4386
+ _newArrowCheck(this, _this3);
4211
4387
 
4212
4388
  return i;
4213
4389
  }.bind(this));
@@ -4217,7 +4393,7 @@ var external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_ = __webpack_re
4217
4393
  }.bind(this)); // check x is defined
4218
4394
 
4219
4395
  ids.forEach(function (id) {
4220
- _newArrowCheck(this, _this11);
4396
+ _newArrowCheck(this, _this2);
4221
4397
 
4222
4398
  if (!this.data.xs[id]) {
4223
4399
  throw new Error("x is not defined for id = \"" + id + "\".");
@@ -4225,19 +4401,19 @@ var external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_ = __webpack_re
4225
4401
  }.bind(this)); // convert to target
4226
4402
 
4227
4403
  var targets = ids.map(function (id, index) {
4228
- var _this13 = this;
4404
+ var _this4 = this;
4229
4405
 
4230
- _newArrowCheck(this, _this11);
4406
+ _newArrowCheck(this, _this2);
4231
4407
 
4232
4408
  var convertedId = config.data_idConverter.bind($$.api)(id),
4233
4409
  xKey = $$.getXKey(id),
4234
4410
  isCategory = isCustomX && isCategorized,
4235
4411
  hasCategory = isCategory && data.map(function (v) {
4236
- _newArrowCheck(this, _this13);
4412
+ _newArrowCheck(this, _this4);
4237
4413
 
4238
4414
  return v.x;
4239
4415
  }.bind(this)).every(function (v) {
4240
- _newArrowCheck(this, _this13);
4416
+ _newArrowCheck(this, _this4);
4241
4417
 
4242
4418
  return config.axis_x_categories.indexOf(v) > -1;
4243
4419
  }.bind(this)),
@@ -4247,7 +4423,7 @@ var external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_ = __webpack_re
4247
4423
  id: convertedId,
4248
4424
  id_org: id,
4249
4425
  values: data.map(function (d, i) {
4250
- _newArrowCheck(this, _this13);
4426
+ _newArrowCheck(this, _this4);
4251
4427
 
4252
4428
  var rawX = d[xKey],
4253
4429
  value = d[id],
@@ -4277,10 +4453,11 @@ var external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_ = __webpack_re
4277
4453
  return {
4278
4454
  x: x,
4279
4455
  value: value,
4280
- id: convertedId
4456
+ id: convertedId,
4457
+ index: -1
4281
4458
  };
4282
4459
  }.bind(this)).filter(function (v) {
4283
- _newArrowCheck(this, _this13);
4460
+ _newArrowCheck(this, _this4);
4284
4461
 
4285
4462
  return isDefined(v.x);
4286
4463
  }.bind(this))
@@ -4288,14 +4465,14 @@ var external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_ = __webpack_re
4288
4465
  }.bind(this)); // finish targets
4289
4466
 
4290
4467
  targets.forEach(function (t) {
4291
- var _this14 = this;
4468
+ var _this5 = this;
4292
4469
 
4293
- _newArrowCheck(this, _this11);
4470
+ _newArrowCheck(this, _this2);
4294
4471
 
4295
4472
  // sort values by its x
4296
4473
  if (config.data_xSort) {
4297
4474
  t.values = t.values.sort(function (v1, v2) {
4298
- _newArrowCheck(this, _this14);
4475
+ _newArrowCheck(this, _this5);
4299
4476
 
4300
4477
  var x1 = v1.x || v1.x === 0 ? v1.x : Infinity,
4301
4478
  x2 = v2.x || v2.x === 0 ? v2.x : Infinity;
@@ -4305,13 +4482,13 @@ var external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_ = __webpack_re
4305
4482
 
4306
4483
 
4307
4484
  t.values.forEach(function (v, i) {
4308
- _newArrowCheck(this, _this14);
4485
+ _newArrowCheck(this, _this5);
4309
4486
 
4310
4487
  return v.index = i;
4311
4488
  }.bind(this)); // this needs to be sorted because its index and value.index is identical
4312
4489
 
4313
4490
  $$.data.xs[t.id].sort(function (v1, v2) {
4314
- _newArrowCheck(this, _this14);
4491
+ _newArrowCheck(this, _this5);
4315
4492
 
4316
4493
  return v1 - v2;
4317
4494
  }.bind(this));
@@ -4322,7 +4499,7 @@ var external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_ = __webpack_re
4322
4499
 
4323
4500
  if (config.data_type) {
4324
4501
  $$.setTargetType($$.mapToIds(targets).filter(function (id) {
4325
- _newArrowCheck(this, _this11);
4502
+ _newArrowCheck(this, _this2);
4326
4503
 
4327
4504
  return !(id in config.data_types);
4328
4505
  }.bind(this)), config.data_type);
@@ -4330,7 +4507,7 @@ var external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_ = __webpack_re
4330
4507
 
4331
4508
 
4332
4509
  targets.forEach(function (d) {
4333
- _newArrowCheck(this, _this11);
4510
+ _newArrowCheck(this, _this2);
4334
4511
 
4335
4512
  return $$.cache.add(d.id_org, d, !0);
4336
4513
  }.bind(this));
@@ -5583,13 +5760,13 @@ var external_commonjs_d3_dsv_commonjs2_d3_dsv_amd_d3_dsv_root_d3_ = __webpack_re
5583
5760
 
5584
5761
 
5585
5762
  $$.cache.reset();
5586
- var data = args.data || $$.convertData(args, function (d) {
5763
+ $$.convertData(args, function (d) {
5587
5764
  _newArrowCheck(this, _this2);
5588
5765
 
5589
- return $$.load($$.convertDataToTargets(d), args);
5766
+ var data = args.data || d;
5767
+ args.append && (data.__append__ = !0);
5768
+ data && $$.load($$.convertDataToTargets(data), args);
5590
5769
  }.bind(this));
5591
- args.append && (data.__append__ = !0);
5592
- data && $$.load($$.convertDataToTargets(data), args);
5593
5770
  },
5594
5771
  unload: function unload(rawTargetIds, customDoneCb) {
5595
5772
  var _this3 = this,
@@ -6132,58 +6309,98 @@ var colorizePattern = function (pattern, color, id) {
6132
6309
  id: id,
6133
6310
  node: node.node()
6134
6311
  };
6135
- }.bind(undefined),
6136
- schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "#8c564b", "#e377c2", "#7f7f7f", "#bcbd22", "#17becf"]; // Replacement of d3.schemeCategory10.
6312
+ }.bind(undefined);
6313
+ /**
6314
+ * Get color pattern from CSS file
6315
+ * CSS should be defined as: background-image: url("#00c73c;#fa7171; ...");
6316
+ * @param {d3Selection} element Chart element
6317
+ * @returns {Array}
6318
+ * @private
6319
+ */
6320
+
6321
+
6322
+ function getColorFromCss(element) {
6323
+ var _this2 = this,
6324
+ cacheKey = KEY.colorPattern,
6325
+ body = browser_doc.body,
6326
+ pattern = body[cacheKey];
6327
+
6328
+ if (!pattern) {
6329
+ var content = element.classed($COLOR.colorPattern, !0).style("background-image");
6330
+ element.classed($COLOR.colorPattern, !1);
6331
+
6332
+ if (content.indexOf(";") > -1) {
6333
+ pattern = content.replace(/url[^#]*|["'()]|(\s|%20)/g, "").split(";").map(function (v) {
6334
+ _newArrowCheck(this, _this2);
6335
+
6336
+ return v.trim().replace(/[\"'\s]/g, "");
6337
+ }.bind(this)).filter(Boolean);
6338
+ body[cacheKey] = pattern;
6339
+ }
6340
+ }
6341
+
6342
+ return pattern;
6343
+ } // Replacement of d3.schemeCategory10.
6137
6344
  // Contained differently depend on d3 version: v4(d3-scale), v5(d3-scale-chromatic)
6138
6345
 
6139
6346
 
6347
+ var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "#8c564b", "#e377c2", "#7f7f7f", "#bcbd22", "#17becf"];
6140
6348
  /* harmony default export */ var internals_color = ({
6141
6349
  /**
6142
- * Get color pattern from CSS file
6143
- * CSS should be defined as: background-image: url("#00c73c;#fa7171; ...");
6144
- * @returns {Array}
6350
+ * Add props color css rule to given selector
6351
+ * @param {Function} fn Color function
6352
+ * @param {string} selector CSS selector
6353
+ * @param {Array} props CSS props list
6354
+ * @returns {Function}
6145
6355
  * @private
6146
6356
  */
6147
- getColorFromCss: function getColorFromCss() {
6148
- var _this2 = this,
6149
- cacheKey = KEY.colorPattern,
6150
- body = browser_doc.body,
6151
- pattern = body[cacheKey];
6152
-
6153
- if (!pattern) {
6154
- var span = browser_doc.createElement("span");
6155
- span.className = $COLOR.colorPattern;
6156
- span.style.display = "none";
6157
- body.appendChild(span);
6158
- var content = win.getComputedStyle(span).backgroundImage;
6159
- span.parentNode.removeChild(span);
6160
-
6161
- if (content.indexOf(";") > -1) {
6162
- pattern = content.replace(/url[^#]*|["'()]|(\s|%20)/g, "").split(";").map(function (v) {
6163
- _newArrowCheck(this, _this2);
6357
+ setColorByRule: function setColorByRule(fn, selector, props) {
6358
+ var _this3 = this,
6359
+ $$ = this,
6360
+ config = $$.config,
6361
+ _$$$state = $$.state,
6362
+ colorRule = _$$$state.colorRule,
6363
+ style = _$$$state.style,
6364
+ colorFn = fn || $$.color;
6164
6365
 
6165
- return v.trim().replace(/[\"'\s]/g, "");
6166
- }.bind(this)).filter(Boolean);
6167
- body[cacheKey] = pattern;
6168
- }
6169
- }
6366
+ return config.boost_useCssRule ? function (selection) {
6367
+ var _this4 = this;
6368
+
6369
+ _newArrowCheck(this, _this3);
6370
+
6371
+ selection.each(function (d) {
6372
+ var _this5 = this;
6373
+
6374
+ _newArrowCheck(this, _this4);
6170
6375
 
6171
- return pattern;
6376
+ var color = colorFn.call($$, d),
6377
+ shapeSelector = "" + $SHAPE.shapes + $$.getTargetSelectorSuffix(d.id) + " ." + selector;
6378
+ shapeSelector in colorRule && style.sheet.deleteRule(colorRule[shapeSelector]);
6379
+ $$.state.colorRule[shapeSelector] = addCssRules(style, shapeSelector, props.map(function (v) {
6380
+ _newArrowCheck(this, _this5);
6381
+
6382
+ return v + ": " + color;
6383
+ }.bind(this)));
6384
+ }.bind(this));
6385
+ }.bind(this) : function () {
6386
+ _newArrowCheck(this, _this3);
6387
+ }.bind(this);
6172
6388
  },
6173
6389
  generateColor: function generateColor() {
6174
- var _this3 = this,
6390
+ var _this6 = this,
6175
6391
  $$ = this,
6392
+ $el = $$.$el,
6176
6393
  config = $$.config,
6177
6394
  colors = config.data_colors,
6178
6395
  callback = config.data_color,
6179
6396
  ids = [],
6180
- pattern = notEmpty(config.color_pattern) ? config.color_pattern : (0,external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleOrdinal)($$.getColorFromCss() || schemeCategory10).range(),
6397
+ pattern = notEmpty(config.color_pattern) ? config.color_pattern : (0,external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleOrdinal)(getColorFromCss($el.chart) || schemeCategory10).range(),
6181
6398
  originalColorPattern = pattern;
6182
6399
 
6183
6400
  if (isFunction(config.color_tiles)) {
6184
6401
  var tiles = config.color_tiles.bind($$.api)(),
6185
6402
  colorizedPatterns = pattern.map(function (p, index) {
6186
- _newArrowCheck(this, _this3);
6403
+ _newArrowCheck(this, _this6);
6187
6404
 
6188
6405
  var color = p.replace(/[#\(\)\s,]/g, ""),
6189
6406
  id = $$.state.datetimeId + "-pattern-" + color + "-" + index;
@@ -6191,7 +6408,7 @@ var colorizePattern = function (pattern, color, id) {
6191
6408
  }.bind(this)); // Add background color to patterns
6192
6409
 
6193
6410
  pattern = colorizedPatterns.map(function (p) {
6194
- _newArrowCheck(this, _this3);
6411
+ _newArrowCheck(this, _this6);
6195
6412
 
6196
6413
  return "url(#" + p.id + ")";
6197
6414
  }.bind(this));
@@ -6250,7 +6467,7 @@ var colorizePattern = function (pattern, color, id) {
6250
6467
  * @private
6251
6468
  */
6252
6469
  generateDataLabelBackgroundColorFilter: function generateDataLabelBackgroundColorFilter(color) {
6253
- var _this4 = this,
6470
+ var _this7 = this,
6254
6471
  $$ = this,
6255
6472
  $el = $$.$el,
6256
6473
  config = $$.config,
@@ -6267,7 +6484,7 @@ var colorizePattern = function (pattern, color, id) {
6267
6484
  }
6268
6485
 
6269
6486
  ids.forEach(function (v) {
6270
- _newArrowCheck(this, _this4);
6487
+ _newArrowCheck(this, _this7);
6271
6488
 
6272
6489
  var id = state.datetimeId + "-labels-bg" + $$.getTargetSelectorSuffix(v) + (color ? $$.getTargetSelectorSuffix(color) : "");
6273
6490
  $el.defs.append("filter").attr("x", "0").attr("y", "0").attr("width", "1").attr("height", "1").attr("id", id).html("<feFlood flood-color=\"" + (v === "" ? backgroundColors : backgroundColors[v]) + "\" /><feComposite in=\"SourceGraphic\"/>");
@@ -6283,7 +6500,7 @@ var colorizePattern = function (pattern, color, id) {
6283
6500
  * @private
6284
6501
  */
6285
6502
  setOverColor: function setOverColor(isOver, d) {
6286
- var _this5 = this,
6503
+ var _this8 = this,
6287
6504
  $$ = this,
6288
6505
  config = $$.config,
6289
6506
  main = $$.$el.main,
@@ -6294,13 +6511,13 @@ var colorizePattern = function (pattern, color, id) {
6294
6511
  color = function (_ref) {
6295
6512
  var id = _ref.id;
6296
6513
 
6297
- _newArrowCheck(this, _this5);
6514
+ _newArrowCheck(this, _this8);
6298
6515
 
6299
6516
  return id in onover ? onover[id] : $$.color(id);
6300
6517
  }.bind(this);
6301
6518
  } else if (isString(color)) {
6302
6519
  color = function () {
6303
- _newArrowCheck(this, _this5);
6520
+ _newArrowCheck(this, _this8);
6304
6521
 
6305
6522
  return onover;
6306
6523
  }.bind(this);
@@ -9029,7 +9246,7 @@ function setRotatePos(d, pos, anchor, isRotated, isInverted) {
9029
9246
  $$ = this,
9030
9247
  value = d.value,
9031
9248
  isCandlestickType = $$.isCandlestickType(d),
9032
- isNegative = value < 0 || isCandlestickType && !((_$$$getCandlestickDat = $$.getCandlestickData(d)) != null && _$$$getCandlestickDat._isUp),
9249
+ isNegative = isNumber(value) && value < 0 || isCandlestickType && !((_$$$getCandlestickDat = $$.getCandlestickData(d)) != null && _$$$getCandlestickDat._isUp),
9033
9250
  x = pos.x,
9034
9251
  y = pos.y,
9035
9252
  gap = 4,
@@ -9099,7 +9316,7 @@ function setRotatePos(d, pos, anchor, isRotated, isInverted) {
9099
9316
 
9100
9317
  return classChartText(d) + classFocus(d);
9101
9318
  }.bind(this)),
9102
- mainTextEnter = mainTextUpdate.enter().append("g").style("opacity", "0").attr("class", classChartText).style("pointer-events", "none");
9319
+ mainTextEnter = mainTextUpdate.enter().append("g").style("opacity", "0").attr("class", classChartText).call($$.setColorByRule($$.updateTextColor, $TEXT.text, ["fill"])).style("pointer-events", "none");
9103
9320
 
9104
9321
  mainTextEnter.append("g").attr("class", classTexts);
9105
9322
  },
@@ -9130,7 +9347,7 @@ function setRotatePos(d, pos, anchor, isRotated, isInverted) {
9130
9347
  }
9131
9348
 
9132
9349
  return config.axis_rotated ? isEndAnchor ? "end" : "start" : "middle";
9133
- }.bind(this)).style("fill", $$.updateTextColor.bind($$)).style("fill-opacity", "0").each(function (d, i, texts) {
9350
+ }.bind(this)).style("fill", $$.colorTextByRule).style("fill-opacity", "0").each(function (d, i, texts) {
9134
9351
  var node = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
9135
9352
  value = d.value;
9136
9353
 
@@ -9227,7 +9444,7 @@ function setRotatePos(d, pos, anchor, isRotated, isInverted) {
9227
9444
  angle = config.data_labels.rotate,
9228
9445
  anchorString = getRotateAnchor(angle),
9229
9446
  rotateString = angle ? "rotate(" + angle + ")" : "";
9230
- $$.$el.text.style("fill", $$.updateTextColor.bind($$)).attr("filter", $$.updateTextBacgroundColor.bind($$)).style("fill-opacity", forFlow ? 0 : $$.opacityForText.bind($$)).each(function (d, i) {
9447
+ $$.$el.text.style("fill", $$.colorTextByRule).attr("filter", $$.updateTextBacgroundColor.bind($$)).style("fill-opacity", forFlow ? 0 : $$.opacityForText.bind($$)).each(function (d, i) {
9231
9448
  // do not apply transition for newly added text elements
9232
9449
  var node = $T(this, !!(withTransition && this.getAttribute("x")), t),
9233
9450
  isInverted = config["axis_" + (axis == null ? void 0 : axis.getId(d.id)) + "_inverted"],
@@ -10727,19 +10944,28 @@ var ChartInternal = /*#__PURE__*/function () {
10727
10944
  var $$ = this,
10728
10945
  config = $$.config,
10729
10946
  state = $$.state,
10730
- $el = $$.$el;
10947
+ $el = $$.$el,
10948
+ useCssRule = config.boost_useCssRule;
10731
10949
  checkModuleImport($$);
10732
10950
  state.hasAxis = !$$.hasArcType();
10733
- state.hasRadar = !state.hasAxis && $$.hasType("radar"); // when 'padding=false' is set, disable axes and subchart. Because they are useless.
10951
+ state.hasRadar = !state.hasAxis && $$.hasType("radar"); // datetime to be used for uniqueness
10734
10952
 
10735
- if (config.padding === !1) {
10736
- config.axis_x_show = !1;
10737
- config.axis_y_show = !1;
10738
- config.axis_y2_show = !1;
10739
- config.subchart_show = !1;
10953
+ state.datetimeId = "bb-" + +new Date() * getRandom();
10954
+
10955
+ if (useCssRule) {
10956
+ // append style element
10957
+ var styleEl = browser_doc.createElement("style"); // styleEl.id = styleId;
10958
+
10959
+ styleEl.type = "text/css";
10960
+ browser_doc.head.appendChild(styleEl);
10961
+ state.style = {
10962
+ rootSelctor: "." + state.datetimeId,
10963
+ sheet: styleEl.sheet
10964
+ }; // used on .destroy()
10965
+
10966
+ $el.style = styleEl;
10740
10967
  }
10741
10968
 
10742
- $$.initParams();
10743
10969
  var bindto = {
10744
10970
  element: config.bindto,
10745
10971
  classname: "bb"
@@ -10757,7 +10983,8 @@ var ChartInternal = /*#__PURE__*/function () {
10757
10983
  $el.chart = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(browser_doc.body.appendChild(browser_doc.createElement("div")));
10758
10984
  }
10759
10985
 
10760
- $el.chart.html("").classed(bindto.classname, !0).style("position", "relative");
10986
+ $el.chart.html("").classed(bindto.classname, !0).classed(state.datetimeId, useCssRule).style("position", "relative");
10987
+ $$.initParams();
10761
10988
  $$.initToRender();
10762
10989
  }
10763
10990
  /**
@@ -10796,9 +11023,12 @@ var ChartInternal = /*#__PURE__*/function () {
10796
11023
  }
10797
11024
 
10798
11025
  if (!isLazy || forced) {
10799
- var convertedData = $$.convertData(config, $$.initWithData);
10800
- convertedData && $$.initWithData(convertedData);
10801
- $$.afterInit();
11026
+ $$.convertData(config, function (res) {
11027
+ _newArrowCheck(this, _this);
11028
+
11029
+ $$.initWithData(res);
11030
+ $$.afterInit();
11031
+ }.bind(this));
10802
11032
  }
10803
11033
  };
10804
11034
 
@@ -10808,13 +11038,30 @@ var ChartInternal = /*#__PURE__*/function () {
10808
11038
  config = $$.config,
10809
11039
  format = $$.format,
10810
11040
  state = $$.state,
10811
- isRotated = config.axis_rotated;
11041
+ isRotated = config.axis_rotated,
11042
+ useCssRule = config.boost_useCssRule;
10812
11043
 
10813
- // datetime to be used for uniqueness
10814
- state.datetimeId = "bb-" + +new Date() * getRandom();
11044
+ // color settings
10815
11045
  $$.color = $$.generateColor();
11046
+ $$.colorByRule = $$.color;
11047
+ $$.colorTextByRule = $$.updateTextColor.bind($$);
10816
11048
  $$.levelColor = $$.generateLevelColor();
10817
11049
 
11050
+ if (useCssRule) {
11051
+ state.colorRule = {}; // to not apply inline color setting
11052
+
11053
+ $$.colorByRule = null;
11054
+ $$.colorTextByRule = null;
11055
+ } // when 'padding=false' is set, disable axes and subchart. Because they are useless.
11056
+
11057
+
11058
+ if (config.padding === !1) {
11059
+ config.axis_x_show = !1;
11060
+ config.axis_y_show = !1;
11061
+ config.axis_y2_show = !1;
11062
+ config.subchart_show = !1;
11063
+ }
11064
+
10818
11065
  if ($$.hasPointType()) {
10819
11066
  $$.point = $$.generatePoint();
10820
11067
  }
@@ -11277,7 +11524,7 @@ var ChartInternal = /*#__PURE__*/function () {
11277
11524
  list.push(function () {
11278
11525
  _newArrowCheck(this, _this9);
11279
11526
 
11280
- return callFn(config.onresize, $$, $$.api);
11527
+ return callFn(config.onresize, $$.api);
11281
11528
  }.bind(this));
11282
11529
 
11283
11530
  if (config.resize_auto) {
@@ -11298,7 +11545,7 @@ var ChartInternal = /*#__PURE__*/function () {
11298
11545
  list.push(function () {
11299
11546
  _newArrowCheck(this, _this9);
11300
11547
 
11301
- callFn(config.onresized, $$, $$.api);
11548
+ callFn(config.onresized, $$.api);
11302
11549
  state.resizing = !1;
11303
11550
  }.bind(this)); // add resize functions
11304
11551
 
@@ -11499,6 +11746,7 @@ function loadConfig(config) {
11499
11746
  $$ = this.internal,
11500
11747
  _$$$$el = $$.$el,
11501
11748
  chart = _$$$$el.chart,
11749
+ style = _$$$$el.style,
11502
11750
  svg = _$$$$el.svg;
11503
11751
 
11504
11752
  if (notEmpty($$)) {
@@ -11510,7 +11758,9 @@ function loadConfig(config) {
11510
11758
  svg.select("*").interrupt();
11511
11759
  $$.resizeFunction.clear();
11512
11760
  win.removeEventListener("resize", $$.resizeFunction);
11513
- chart.classed("bb", !1).style("position", null).selectChildren().remove(); // releasing own references
11761
+ chart.classed("bb", !1).style("position", null).selectChildren().remove(); // remove <style> element added by boost.useCssRule option
11762
+
11763
+ style && style.parentNode.removeChild(style); // releasing own references
11514
11764
 
11515
11765
  Object.keys(this).forEach(function (key) {
11516
11766
  var _this2 = this;
@@ -13616,158 +13866,173 @@ extend(regions, {
13616
13866
  flow: function flow(args) {
13617
13867
  var _this = this,
13618
13868
  $$ = this.internal,
13619
- data,
13620
- domain,
13621
- length = 0,
13622
- tail = 0,
13623
- diff,
13624
- to;
13869
+ data;
13625
13870
 
13626
13871
  if (args.json || args.rows || args.columns) {
13627
- data = $$.convertData(args);
13628
- }
13872
+ $$.convertData(args, function (res) {
13873
+ _newArrowCheck(this, _this);
13629
13874
 
13630
- if ($$.state.redrawing || !data || !isTabVisible()) {
13631
- return;
13875
+ data = res;
13876
+
13877
+ _();
13878
+ }.bind(this));
13632
13879
  }
13880
+ /**
13881
+ * Process flows
13882
+ * @private
13883
+ */
13633
13884
 
13634
- var notfoundIds = [],
13635
- orgDataCount = $$.getMaxDataCount(),
13636
- targets = $$.convertDataToTargets(data, !0),
13637
- isTimeSeries = $$.axis.isTimeSeries();
13638
- // Update/Add data
13639
- $$.data.targets.forEach(function (t) {
13640
- _newArrowCheck(this, _this);
13641
13885
 
13642
- var found = !1;
13886
+ function _() {
13887
+ var _this2 = this,
13888
+ domain,
13889
+ length = 0,
13890
+ tail = 0,
13891
+ diff,
13892
+ to;
13643
13893
 
13644
- for (var i = 0; i < targets.length; i++) {
13645
- if (t.id === targets[i].id) {
13646
- found = !0;
13894
+ if ($$.state.redrawing || !data || !isTabVisible()) {
13895
+ return;
13896
+ }
13647
13897
 
13648
- if (t.values[t.values.length - 1]) {
13649
- tail = t.values[t.values.length - 1].index + 1;
13650
- }
13898
+ var notfoundIds = [],
13899
+ orgDataCount = $$.getMaxDataCount(),
13900
+ targets = $$.convertDataToTargets(data, !0),
13901
+ isTimeSeries = $$.axis.isTimeSeries();
13902
+ // Update/Add data
13903
+ $$.data.targets.forEach(function (t) {
13904
+ _newArrowCheck(this, _this2);
13651
13905
 
13652
- length = targets[i].values.length;
13906
+ var found = !1;
13653
13907
 
13654
- for (var j = 0; j < length; j++) {
13655
- targets[i].values[j].index = tail + j;
13908
+ for (var i = 0; i < targets.length; i++) {
13909
+ if (t.id === targets[i].id) {
13910
+ found = !0;
13656
13911
 
13657
- if (!isTimeSeries) {
13658
- targets[i].values[j].x = tail + j;
13912
+ if (t.values[t.values.length - 1]) {
13913
+ tail = t.values[t.values.length - 1].index + 1;
13659
13914
  }
13660
- }
13661
-
13662
- t.values = t.values.concat(targets[i].values);
13663
- targets.splice(i, 1);
13664
- break;
13665
- }
13666
- }
13667
13915
 
13668
- found || notfoundIds.push(t.id);
13669
- }.bind(this)); // Append null for not found targets
13916
+ length = targets[i].values.length;
13670
13917
 
13671
- $$.data.targets.forEach(function (t) {
13672
- _newArrowCheck(this, _this);
13918
+ for (var j = 0; j < length; j++) {
13919
+ targets[i].values[j].index = tail + j;
13673
13920
 
13674
- for (var i = 0; i < notfoundIds.length; i++) {
13675
- if (t.id === notfoundIds[i]) {
13676
- tail = t.values[t.values.length - 1].index + 1;
13921
+ if (!isTimeSeries) {
13922
+ targets[i].values[j].x = tail + j;
13923
+ }
13924
+ }
13677
13925
 
13678
- for (var j = 0; j < length; j++) {
13679
- t.values.push({
13680
- id: t.id,
13681
- index: tail + j,
13682
- x: isTimeSeries ? $$.getOtherTargetX(tail + j) : tail + j,
13683
- value: null
13684
- });
13926
+ t.values = t.values.concat(targets[i].values);
13927
+ targets.splice(i, 1);
13928
+ break;
13685
13929
  }
13686
13930
  }
13687
- }
13688
- }.bind(this)); // Generate null values for new target
13689
13931
 
13690
- if ($$.data.targets.length) {
13691
- targets.forEach(function (t) {
13692
- var _this2 = this;
13932
+ found || notfoundIds.push(t.id);
13933
+ }.bind(this)); // Append null for not found targets
13693
13934
 
13694
- _newArrowCheck(this, _this);
13935
+ $$.data.targets.forEach(function (t) {
13936
+ _newArrowCheck(this, _this2);
13695
13937
 
13696
- var missing = [];
13938
+ for (var i = 0; i < notfoundIds.length; i++) {
13939
+ if (t.id === notfoundIds[i]) {
13940
+ tail = t.values[t.values.length - 1].index + 1;
13697
13941
 
13698
- for (var i = $$.data.targets[0].values[0].index; i < tail; i++) {
13699
- missing.push({
13700
- id: t.id,
13701
- index: i,
13702
- x: isTimeSeries ? $$.getOtherTargetX(i) : i,
13703
- value: null
13704
- });
13942
+ for (var j = 0; j < length; j++) {
13943
+ t.values.push({
13944
+ id: t.id,
13945
+ index: tail + j,
13946
+ x: isTimeSeries ? $$.getOtherTargetX(tail + j) : tail + j,
13947
+ value: null
13948
+ });
13949
+ }
13950
+ }
13705
13951
  }
13952
+ }.bind(this)); // Generate null values for new target
13953
+
13954
+ if ($$.data.targets.length) {
13955
+ targets.forEach(function (t) {
13956
+ var _this3 = this;
13706
13957
 
13707
- t.values.forEach(function (v) {
13708
13958
  _newArrowCheck(this, _this2);
13709
13959
 
13710
- v.index += tail;
13960
+ var missing = [];
13711
13961
 
13712
- if (!isTimeSeries) {
13713
- v.x += tail;
13962
+ for (var i = $$.data.targets[0].values[0].index; i < tail; i++) {
13963
+ missing.push({
13964
+ id: t.id,
13965
+ index: i,
13966
+ x: isTimeSeries ? $$.getOtherTargetX(i) : i,
13967
+ value: null
13968
+ });
13714
13969
  }
13970
+
13971
+ t.values.forEach(function (v) {
13972
+ _newArrowCheck(this, _this3);
13973
+
13974
+ v.index += tail;
13975
+
13976
+ if (!isTimeSeries) {
13977
+ v.x += tail;
13978
+ }
13979
+ }.bind(this));
13980
+ t.values = missing.concat(t.values);
13715
13981
  }.bind(this));
13716
- t.values = missing.concat(t.values);
13717
- }.bind(this));
13718
- }
13982
+ }
13719
13983
 
13720
- $$.data.targets = $$.data.targets.concat(targets); // add remained
13721
- // check data count because behavior needs to change when it"s only one
13722
- // const dataCount = $$.getMaxDataCount();
13984
+ $$.data.targets = $$.data.targets.concat(targets); // add remained
13985
+ // check data count because behavior needs to change when it"s only one
13986
+ // const dataCount = $$.getMaxDataCount();
13723
13987
 
13724
- var baseTarget = $$.data.targets[0],
13725
- baseValue = baseTarget.values[0];
13988
+ var baseTarget = $$.data.targets[0],
13989
+ baseValue = baseTarget.values[0];
13726
13990
 
13727
- // Update length to flow if needed
13728
- if (isDefined(args.to)) {
13729
- length = 0;
13730
- to = isTimeSeries ? parseDate.call($$, args.to) : args.to;
13731
- baseTarget.values.forEach(function (v) {
13732
- _newArrowCheck(this, _this);
13991
+ // Update length to flow if needed
13992
+ if (isDefined(args.to)) {
13993
+ length = 0;
13994
+ to = isTimeSeries ? parseDate.call($$, args.to) : args.to;
13995
+ baseTarget.values.forEach(function (v) {
13996
+ _newArrowCheck(this, _this2);
13733
13997
 
13734
- v.x < to && length++;
13735
- }.bind(this));
13736
- } else if (isDefined(args.length)) {
13737
- length = args.length;
13738
- } // If only one data, update the domain to flow from left edge of the chart
13998
+ v.x < to && length++;
13999
+ }.bind(this));
14000
+ } else if (isDefined(args.length)) {
14001
+ length = args.length;
14002
+ } // If only one data, update the domain to flow from left edge of the chart
13739
14003
 
13740
14004
 
13741
- if (!orgDataCount) {
13742
- if (isTimeSeries) {
13743
- diff = baseTarget.values.length > 1 ? baseTarget.values[baseTarget.values.length - 1].x - baseValue.x : baseValue.x - $$.getXDomain($$.data.targets)[0];
13744
- } else {
13745
- diff = 1;
13746
- }
14005
+ if (!orgDataCount) {
14006
+ if (isTimeSeries) {
14007
+ diff = baseTarget.values.length > 1 ? baseTarget.values[baseTarget.values.length - 1].x - baseValue.x : baseValue.x - $$.getXDomain($$.data.targets)[0];
14008
+ } else {
14009
+ diff = 1;
14010
+ }
13747
14011
 
13748
- domain = [baseValue.x - diff, baseValue.x];
13749
- } else if (orgDataCount === 1 && isTimeSeries) {
13750
- diff = (baseTarget.values[baseTarget.values.length - 1].x - baseValue.x) / 2;
13751
- domain = [new Date(+baseValue.x - diff), new Date(+baseValue.x + diff)];
13752
- }
14012
+ domain = [baseValue.x - diff, baseValue.x];
14013
+ } else if (orgDataCount === 1 && isTimeSeries) {
14014
+ diff = (baseTarget.values[baseTarget.values.length - 1].x - baseValue.x) / 2;
14015
+ domain = [new Date(+baseValue.x - diff), new Date(+baseValue.x + diff)];
14016
+ }
13753
14017
 
13754
- domain && $$.updateXDomain(null, !0, !0, !1, domain); // Set targets
14018
+ domain && $$.updateXDomain(null, !0, !0, !1, domain); // Set targets
13755
14019
 
13756
- $$.updateTargets($$.data.targets); // Redraw with new targets
14020
+ $$.updateTargets($$.data.targets); // Redraw with new targets
13757
14021
 
13758
- $$.redraw({
13759
- flow: {
13760
- index: baseValue.index,
13761
- length: length,
13762
- duration: isValue(args.duration) ? args.duration : $$.config.transition_duration,
13763
- done: args.done,
13764
- orgDataCount: orgDataCount
13765
- },
13766
- withLegend: !0,
13767
- withTransition: orgDataCount > 1,
13768
- withTrimXDomain: !1,
13769
- withUpdateXAxis: !0
13770
- });
14022
+ $$.redraw({
14023
+ flow: {
14024
+ index: baseValue.index,
14025
+ length: length,
14026
+ duration: isValue(args.duration) ? args.duration : $$.config.transition_duration,
14027
+ done: args.done,
14028
+ orgDataCount: orgDataCount
14029
+ },
14030
+ withLegend: !0,
14031
+ withTransition: orgDataCount > 1,
14032
+ withTrimXDomain: !1,
14033
+ withUpdateXAxis: !0
14034
+ });
14035
+ }
13771
14036
  }
13772
14037
  });
13773
14038
  // EXTERNAL MODULE: external {"commonjs":"d3-axis","commonjs2":"d3-axis","amd":"d3-axis","root":"d3"}
@@ -20121,8 +20386,7 @@ var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate
20121
20386
 
20122
20387
  if ($$.isAreaType(d)) {
20123
20388
  var area = (0,external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.area)();
20124
- area = isRotated ? area.y(xValue).x0(value0).x1(value1) : area.x(xValue) // @ts-ignore
20125
- .y0(config.area_above ? 0 : value0).y1(value1);
20389
+ area = isRotated ? area.y(xValue).x0(value0).x1(value1) : area.x(xValue).y0(config.area_above ? 0 : config.area_below ? $$.state.height : value0).y1(value1);
20126
20390
 
20127
20391
  if (!lineConnectNull) {
20128
20392
  area = area.defined(function (d) {
@@ -20233,7 +20497,7 @@ var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate
20233
20497
  _newArrowCheck(this, _this);
20234
20498
 
20235
20499
  return isSelectable != null && isSelectable.bind != null && isSelectable.bind($$.api)(d) ? "pointer" : null;
20236
- }.bind(this));
20500
+ }.bind(this)).call($$.setColorByRule(null, $BAR.bar, ["fill"]));
20237
20501
  },
20238
20502
 
20239
20503
  /**
@@ -20255,7 +20519,7 @@ var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate
20255
20519
  initialOpacity = $$.initialOpacity.bind($$),
20256
20520
  bar = $root.main.selectAll("." + $BAR.bars).selectAll("." + $BAR.bar).data($$.labelishData.bind($$));
20257
20521
  $T(bar.exit(), withTransition).style("opacity", "0").remove();
20258
- $root.bar = bar.enter().append("path").attr("class", classBar).style("fill", $$.color).merge(bar).style("opacity", initialOpacity);
20522
+ $root.bar = bar.enter().append("path").attr("class", classBar).style("fill", $$.colorByRule).merge(bar).style("opacity", initialOpacity);
20259
20523
  },
20260
20524
 
20261
20525
  /**
@@ -20280,7 +20544,7 @@ var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate
20280
20544
  _newArrowCheck(this, _this3);
20281
20545
 
20282
20546
  return (isNumber(d.value) || $$.isBarRangeType(d)) && drawFn(d);
20283
- }.bind(this)).style("fill", $$.color).style("opacity", null)];
20547
+ }.bind(this)).style("fill", $$.colorByRule).style("opacity", null)];
20284
20548
  },
20285
20549
 
20286
20550
  /**
@@ -20396,7 +20660,7 @@ var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate
20396
20660
  return v.values.filter(function (v2) {
20397
20661
  _newArrowCheck(this, _this6);
20398
20662
 
20399
- return v2.index === index && (value > 0 ? v2.value > 0 : v2.value < 0);
20663
+ return v2.index === index && (isNumber(value) && value > 0 ? v2.value > 0 : v2.value < 0);
20400
20664
  }.bind(this))[0];
20401
20665
  }.bind(this)).filter(Boolean).map(function (v) {
20402
20666
  _newArrowCheck(this, _this5);
@@ -20433,11 +20697,12 @@ var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate
20433
20697
  var y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id)),
20434
20698
  offset = barOffset(d, i) || y0,
20435
20699
  width = isNumber(barW) ? barW : barW[d.id] || barW._$width,
20700
+ value = d.value,
20436
20701
  posX = barX(d),
20437
20702
  posY = barY(d);
20438
20703
 
20439
20704
  // fix posY not to overflow opposite quadrant
20440
- if (config.axis_rotated && (d.value > 0 && posY < y0 || d.value < 0 && y0 < posY)) {
20705
+ if (config.axis_rotated && (value > 0 && posY < y0 || value < 0 && y0 < posY)) {
20441
20706
  posY = y0;
20442
20707
  }
20443
20708
 
@@ -21348,7 +21613,7 @@ var getTransitionName = function () {
21348
21613
  _newArrowCheck(this, _this2);
21349
21614
 
21350
21615
  return isFunction(isSelectable) && isSelectable(d) ? "pointer" : null;
21351
- }.bind(this)).style("opacity", function () {
21616
+ }.bind(this)).call($$.setColorByRule(null, $CIRCLE.circle, ["fill", "stroke"])).style("opacity", function () {
21352
21617
  var parent = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this.parentNode); // if the parent node is .bb-chart-circles (bubble, scatter), initialize <g bb-circles> with opacity "0"
21353
21618
 
21354
21619
  return parent.attr("class").indexOf($CIRCLE.chartCircles) > -1 ? "0" : null;
@@ -21387,8 +21652,8 @@ var getTransitionName = function () {
21387
21652
  return $$.isLineType(d) && $$.shouldDrawPointsForLine(d) || $$.isBubbleType(d) || $$.isRadarType(d) || $$.isScatterType(d) ? focusOnly ? [d.values[0]] : d.values : [];
21388
21653
  }.bind(this));
21389
21654
  circles.exit().remove();
21390
- circles.enter().filter(Boolean).append($$.point("create", this, $$.pointR.bind($$), $$.color));
21391
- $root.circle = $root.main.selectAll("." + $CIRCLE.circles + " ." + $CIRCLE.circle).style("stroke", $$.color).style("opacity", $$.initialOpacityForCircle.bind($$));
21655
+ circles.enter().filter(Boolean).append($$.point("create", this, $$.pointR.bind($$), $$.colorByRule));
21656
+ $root.circle = $root.main.selectAll("." + $CIRCLE.circles + " ." + $CIRCLE.circle).style("stroke", $$.colorByRule).style("opacity", $$.initialOpacityForCircle.bind($$));
21392
21657
  }
21393
21658
  },
21394
21659
  redrawCircle: function redrawCircle(cx, cy, withTransition, flow, isSub) {
@@ -21407,7 +21672,7 @@ var getTransitionName = function () {
21407
21672
  return [];
21408
21673
  }
21409
21674
 
21410
- var fn = $$.point("update", $$, cx, cy, $$.color, withTransition, flow, selectedCircles),
21675
+ var fn = $$.point("update", $$, cx, cy, $$.colorByRule, withTransition, flow, selectedCircles),
21411
21676
  posAttr = $$.isCirclePoint() ? "c" : "",
21412
21677
  t = getRandom(),
21413
21678
  opacityStyleFn = $$.opacityForCircle.bind($$),
@@ -21440,7 +21705,7 @@ var getTransitionName = function () {
21440
21705
  var cx = (hasRadar ? $$.radarCircleX : $$.circleX).bind($$),
21441
21706
  cy = (hasRadar ? $$.radarCircleY : $$.circleY).bind($$),
21442
21707
  withTransition = toggling || isUndefined(d),
21443
- fn = $$.point("update", $$, cx, cy, $$.color, resizing ? !1 : withTransition);
21708
+ fn = $$.point("update", $$, cx, cy, $$.colorByRule, resizing ? !1 : withTransition);
21444
21709
 
21445
21710
  if (d) {
21446
21711
  circle = circle.filter(function (t) {
@@ -21541,7 +21806,12 @@ var getTransitionName = function () {
21541
21806
  return (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).classed($COMMON.EXPANDED);
21542
21807
  }).classed($COMMON.EXPANDED, !1);
21543
21808
  circles.attr("r", r);
21544
- $$.isCirclePoint() || circles.attr("transform", "scale(" + r(circles) / $$.config.point_r + ")");
21809
+
21810
+ if (!$$.isCirclePoint()) {
21811
+ var _scale = r(circles) / $$.config.point_r;
21812
+
21813
+ circles.attr("transform", _scale !== 1 ? "scale(" + _scale + ")" : null);
21814
+ }
21545
21815
  },
21546
21816
  pointR: function (d) {
21547
21817
  var $$ = this,
@@ -21715,7 +21985,7 @@ var getTransitionName = function () {
21715
21985
  };
21716
21986
  },
21717
21987
  custom: {
21718
- create: function create(element, id, sizeFn, fillStyleFn) {
21988
+ create: function create(element, id, fillStyleFn) {
21719
21989
  return element.append("use").attr("xlink:href", "#" + id).attr("class", this.updatePointClass.bind(this)).style("fill", fillStyleFn).node();
21720
21990
  },
21721
21991
  update: function update(element, xPosFn, yPosFn, fillStyleFn, withTransition, flow, selectedCircles) {
@@ -21865,8 +22135,10 @@ function getDataMax($$) {
21865
22135
  * @private
21866
22136
  */
21867
22137
  getPolarOuterRadius: function getPolarOuterRadius(d, outerRadius) {
21868
- var dataMax = getDataMax(this);
21869
- return (d == null ? void 0 : d.data.values[0].value) / dataMax * outerRadius;
22138
+ var _d$data$values$0$valu,
22139
+ dataMax = getDataMax(this);
22140
+
22141
+ return ((_d$data$values$0$valu = d == null ? void 0 : d.data.values[0].value) != null ? _d$data$values$0$valu : 0) / dataMax * outerRadius;
21870
22142
  },
21871
22143
 
21872
22144
  /**
@@ -22486,7 +22758,9 @@ var cacheKey = KEY.radarPoints;
22486
22758
  * @memberof Options
22487
22759
  * @type {object}
22488
22760
  * @property {object} area Area object
22489
- * @property {boolean} [area.above=false] Set background area above the data chart line.
22761
+ * @property {boolean} [area.above=false] Set background area `above` the data chart line.
22762
+ * @property {boolean} [area.below=false] Set background area `below` the data chart line.
22763
+ * - **NOTE**: Can't be used along with `above` option. When above & below options are set to true, `above` will be prioritized.
22490
22764
  * @property {boolean} [area.front=true] Set area node to be positioned over line node.
22491
22765
  * @property {boolean|object} [area.linearGradient=false] Set the linear gradient on area.<br><br>
22492
22766
  * Or customize by giving below object value:
@@ -22497,10 +22771,12 @@ var cacheKey = KEY.radarPoints;
22497
22771
  * @see [MDN's &lt;linearGradient>](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/linearGradient), [&lt;stop>](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/stop)
22498
22772
  * @see [Demo](https://naver.github.io/billboard.js/demo/#Chart.AreaChart)
22499
22773
  * @see [Demo: above](https://naver.github.io/billboard.js/demo/#AreaChartOptions.Above)
22774
+ * @see [Demo: below](https://naver.github.io/billboard.js/demo/#AreaChartOptions.Below)
22500
22775
  * @see [Demo: linearGradient](https://naver.github.io/billboard.js/demo/#AreaChartOptions.LinearGradient)
22501
22776
  * @example
22502
22777
  * area: {
22503
22778
  * above: true,
22779
+ * below: false,
22504
22780
  * zerobased: false,
22505
22781
  *
22506
22782
  * // <g class='bb-areas'> will be positioned behind the line <g class='bb-lines'> in stacking order
@@ -22532,6 +22808,7 @@ var cacheKey = KEY.radarPoints;
22532
22808
  * }
22533
22809
  */
22534
22810
  area_above: !1,
22811
+ area_below: !1,
22535
22812
  area_front: !0,
22536
22813
  area_linearGradient: !1,
22537
22814
  area_zerobased: !0
@@ -25602,7 +25879,7 @@ var _defaults = {},
25602
25879
  * bb.version; // "1.0.0"
25603
25880
  * @memberof bb
25604
25881
  */
25605
- version: "3.5.0-next.1",
25882
+ version: "3.5.0-next.2",
25606
25883
 
25607
25884
  /**
25608
25885
  * Generate chart
@@ -25737,7 +26014,7 @@ var _defaults = {},
25737
26014
  };
25738
26015
  /**
25739
26016
  * @namespace bb
25740
- * @version 3.5.0-next.1
26017
+ * @version 3.5.0-next.2
25741
26018
  */
25742
26019
  ;// CONCATENATED MODULE: ./src/index.ts
25743
26020