billboard.js 3.16.0-next.2 → 3.16.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.
Files changed (46) hide show
  1. package/dist/billboard.css +1 -1
  2. package/dist/billboard.js +95 -91
  3. package/dist/billboard.min.css +1 -1
  4. package/dist/billboard.min.js +8 -8
  5. package/dist/billboard.pkgd.js +95 -91
  6. package/dist/billboard.pkgd.min.js +13 -13
  7. package/dist/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  8. package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
  9. package/dist/plugin/billboardjs-plugin-sparkline.js +2 -2
  10. package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
  11. package/dist/plugin/billboardjs-plugin-stanford.js +2 -2
  12. package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
  13. package/dist/plugin/billboardjs-plugin-tableview.js +2 -2
  14. package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
  15. package/dist/plugin/billboardjs-plugin-textoverlap.js +2 -2
  16. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +3 -3
  17. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +2 -2
  18. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +2 -2
  19. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +2 -2
  20. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +2 -2
  21. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +2 -2
  22. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +2 -2
  23. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +2 -2
  24. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +2 -2
  25. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +2 -2
  26. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +2 -2
  27. package/dist/theme/dark.css +1 -1
  28. package/dist/theme/dark.min.css +1 -1
  29. package/dist/theme/datalab.css +1 -1
  30. package/dist/theme/datalab.min.css +1 -1
  31. package/dist/theme/graph.css +1 -1
  32. package/dist/theme/graph.min.css +1 -1
  33. package/dist/theme/insight.css +1 -1
  34. package/dist/theme/insight.min.css +1 -1
  35. package/dist/theme/modern.css +1 -1
  36. package/dist/theme/modern.min.css +1 -1
  37. package/dist-esm/billboard.js +128 -114
  38. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  39. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +2 -2
  40. package/dist-esm/plugin/billboardjs-plugin-stanford.js +2 -2
  41. package/dist-esm/plugin/billboardjs-plugin-tableview.js +2 -2
  42. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
  43. package/package.json +11 -11
  44. package/src/ChartInternal/ChartInternal.ts +51 -60
  45. package/src/ChartInternal/data/convert.ts +71 -45
  46. package/src/config/Options/axis/y2.ts +0 -13
@@ -5,7 +5,7 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 3.16.0-next.2
8
+ * @version 3.16.0
9
9
  *
10
10
  * All-in-one packaged file for ease use of 'billboard.js' with dependant d3.js modules & polyfills.
11
11
  * - @types/d3-selection ^3.0.11
@@ -28796,6 +28796,35 @@ function getDataKeyForJson(keysParam, config) {
28796
28796
  }
28797
28797
  return keys;
28798
28798
  }
28799
+ function setXS(ids, data, params) {
28800
+ const $$ = this;
28801
+ const { config } = $$;
28802
+ let xsData;
28803
+ ids.forEach((id) => {
28804
+ const xKey = $$.getXKey(id);
28805
+ if (params.customX || params.timeSeries) {
28806
+ if (params.xs.indexOf(xKey) >= 0) {
28807
+ xsData = (params.appendXs && $$.data.xs[id] || []).concat(
28808
+ data.map((d, i) => {
28809
+ const rawX = isValue(d[xKey]);
28810
+ return rawX ? $$.generateTargetX(rawX, id, i) : false;
28811
+ }).filter((v) => v !== false)
28812
+ );
28813
+ } else if (config.data_x) {
28814
+ xsData = this.getOtherTargetXs();
28815
+ } else if (notEmpty(config.data_xs)) {
28816
+ xsData = $$.getXValuesOfXKey(xKey, $$.data.targets);
28817
+ }
28818
+ } else {
28819
+ xsData = data.map((d, i) => i);
28820
+ }
28821
+ if (xsData) {
28822
+ $$.data.xs[id] = xsData;
28823
+ } else {
28824
+ throw new Error(`x is not defined for id = "${id}".`);
28825
+ }
28826
+ });
28827
+ }
28799
28828
  /* harmony default export */ var convert = ({
28800
28829
  /**
28801
28830
  * Convert data according its type
@@ -28837,18 +28866,17 @@ function getDataKeyForJson(keysParam, config) {
28837
28866
  throw Error("url or json or rows or columns is required.");
28838
28867
  }
28839
28868
  },
28869
+ /**
28870
+ * Convert data to targets
28871
+ * @param {object[]} data Data to convert
28872
+ * @param {boolean} appendXs Whether to append xs
28873
+ * @returns {IData[]} Converted targets
28874
+ * @private
28875
+ */
28840
28876
  convertDataToTargets(data, appendXs) {
28841
28877
  const $$ = this;
28842
28878
  const { axis, config, state } = $$;
28843
28879
  const chartType = config.data_type;
28844
- let isCategorized = false;
28845
- let isTimeSeries = false;
28846
- let isCustomX = false;
28847
- if (axis) {
28848
- isCategorized = axis.isCategorized();
28849
- isTimeSeries = axis.isTimeSeries();
28850
- isCustomX = axis.isCustomX();
28851
- }
28852
28880
  const dataKeys = Object.keys(data[0] || {});
28853
28881
  const { ids, xs } = dataKeys.length ? dataKeys.reduce((acc, key) => {
28854
28882
  if ($$.isX.call($$, key)) {
@@ -28858,33 +28886,19 @@ function getDataKeyForJson(keysParam, config) {
28858
28886
  }
28859
28887
  return acc;
28860
28888
  }, { ids: [], xs: [] }) : { ids: [], xs: [] };
28861
- let xsData;
28862
- ids.forEach((id) => {
28863
- const xKey = this.getXKey(id);
28864
- if (isCustomX || isTimeSeries) {
28865
- if (xs.indexOf(xKey) >= 0) {
28866
- xsData = (appendXs && $$.data.xs[id] || []).concat(
28867
- data.map((d) => d[xKey]).filter(isValue).map((rawX, i) => $$.generateTargetX(rawX, id, i))
28868
- );
28869
- } else if (config.data_x) {
28870
- xsData = this.getOtherTargetXs();
28871
- } else if (notEmpty(config.data_xs)) {
28872
- xsData = $$.getXValuesOfXKey(xKey, $$.data.targets);
28873
- }
28874
- } else {
28875
- xsData = data.map((d, i) => i);
28876
- }
28877
- xsData && (this.data.xs[id] = xsData);
28878
- });
28879
- ids.forEach((id) => {
28880
- if (!this.data.xs[id]) {
28881
- throw new Error(`x is not defined for id = "${id}".`);
28882
- }
28883
- });
28889
+ const params = {
28890
+ appendXs,
28891
+ xs,
28892
+ idConverter: config.data_idConverter.bind($$.api),
28893
+ categorized: axis == null ? void 0 : axis.isCategorized(),
28894
+ timeSeries: axis == null ? void 0 : axis.isTimeSeries(),
28895
+ customX: axis == null ? void 0 : axis.isCustomX()
28896
+ };
28897
+ setXS.bind($$)(ids, data, params);
28884
28898
  const targets = ids.map((id, index) => {
28885
28899
  const convertedId = config.data_idConverter.bind($$.api)(id);
28886
28900
  const xKey = $$.getXKey(id);
28887
- const isCategory = isCustomX && isCategorized;
28901
+ const isCategory = params.customX && params.categorized;
28888
28902
  const hasCategory = isCategory && (() => {
28889
28903
  const categorySet = new Set(config.axis_x_categories);
28890
28904
  return data.every((v) => categorySet.has(v.x));
@@ -36284,14 +36298,15 @@ class ChartInternal {
36284
36298
  init() {
36285
36299
  const $$ = this;
36286
36300
  const { config, state, $el } = $$;
36287
- const useCssRule = config.boost_useCssRule;
36301
+ const { boost_useCssRule, bindto } = config;
36288
36302
  checkModuleImport($$);
36303
+ const hasArcType = $$.hasArcType();
36289
36304
  state.hasRadar = !state.hasAxis && $$.hasType("radar");
36290
36305
  state.hasFunnel = !state.hasAxis && $$.hasType("funnel");
36291
36306
  state.hasTreemap = !state.hasAxis && $$.hasType("treemap");
36292
- state.hasAxis = !$$.hasArcType() && !state.hasFunnel && !state.hasTreemap;
36307
+ state.hasAxis = !hasArcType && !state.hasFunnel && !state.hasTreemap;
36293
36308
  state.datetimeId = `bb-${+/* @__PURE__ */ new Date() * getRandom()}`;
36294
- if (useCssRule) {
36309
+ if (boost_useCssRule) {
36295
36310
  const styleEl = browser_doc.createElement("style");
36296
36311
  styleEl.type = "text/css";
36297
36312
  browser_doc.head.appendChild(styleEl);
@@ -36301,19 +36316,19 @@ class ChartInternal {
36301
36316
  };
36302
36317
  $el.style = styleEl;
36303
36318
  }
36304
- const bindto = {
36305
- element: config.bindto,
36319
+ const bindConfig = {
36320
+ element: bindto,
36306
36321
  classname: "bb"
36307
36322
  };
36308
- if (isObject(config.bindto)) {
36309
- bindto.element = config.bindto.element || "#chart";
36310
- bindto.classname = config.bindto.classname || bindto.classname;
36323
+ if (isObject(bindto)) {
36324
+ bindConfig.element = bindto.element || "#chart";
36325
+ bindConfig.classname = bindto.classname || bindConfig.classname;
36311
36326
  }
36312
- $el.chart = isFunction(bindto.element.node) ? config.bindto.element : src_select(bindto.element || []);
36327
+ $el.chart = isFunction(bindConfig.element.node) ? bindto.element : src_select(bindConfig.element || []);
36313
36328
  if ($el.chart.empty()) {
36314
36329
  $el.chart = src_select(browser_doc.body.appendChild(browser_doc.createElement("div")));
36315
36330
  }
36316
- $el.chart.html("").classed(bindto.classname, true).classed(state.datetimeId, useCssRule).style("position", "relative");
36331
+ $el.chart.html("").classed(bindConfig.classname, true).classed(state.datetimeId, boost_useCssRule).style("position", "relative");
36317
36332
  $$.initParams();
36318
36333
  $$.initToRender();
36319
36334
  }
@@ -36350,7 +36365,6 @@ class ChartInternal {
36350
36365
  var _a;
36351
36366
  const $$ = this;
36352
36367
  const { config, format: format2, state } = $$;
36353
- const isRotated = config.axis_rotated;
36354
36368
  $$.color = $$.generateColor();
36355
36369
  $$.levelColor = $$.generateLevelColor();
36356
36370
  if (config.padding === false) {
@@ -36367,7 +36381,7 @@ class ChartInternal {
36367
36381
  format2.extraLineClasses = $$.generateExtraLineClass();
36368
36382
  format2.dataTime = config.data_xLocaltime ? timeParse : utcParse;
36369
36383
  format2.axisTime = config.axis_x_localtime ? timeFormat : utcFormat;
36370
- const isDragZoom = $$.config.zoom_enabled && $$.config.zoom_type === "drag";
36384
+ const isDragZoom = config.zoom_enabled && config.zoom_type === "drag";
36371
36385
  format2.defaultAxisTime = (d) => {
36372
36386
  const { x, zoom } = $$.scale;
36373
36387
  const isZoomed = isDragZoom ? zoom : zoom && x.orgDomain().toString() !== zoom.domain().toString();
@@ -36375,12 +36389,13 @@ class ChartInternal {
36375
36389
  return format2.axisTime(specifier)(d);
36376
36390
  };
36377
36391
  }
36378
- state.isLegendRight = config.legend_position === "right";
36379
- state.isLegendInset = config.legend_position === "inset";
36380
- state.isLegendTop = config.legend_inset_anchor === "top-left" || config.legend_inset_anchor === "top-right";
36381
- state.isLegendLeft = config.legend_inset_anchor === "top-left" || config.legend_inset_anchor === "bottom-left";
36392
+ const { legend_position, legend_inset_anchor, axis_rotated } = config;
36393
+ state.isLegendRight = legend_position === "right";
36394
+ state.isLegendInset = legend_position === "inset";
36395
+ state.isLegendTop = legend_inset_anchor === "top-left" || legend_inset_anchor === "top-right";
36396
+ state.isLegendLeft = legend_inset_anchor === "top-left" || legend_inset_anchor === "bottom-left";
36382
36397
  state.rotatedPadding.top = $$.getResettedPadding(state.rotatedPadding.top);
36383
- state.rotatedPadding.right = isRotated && !config.axis_x_show ? 0 : 30;
36398
+ state.rotatedPadding.right = axis_rotated && !config.axis_x_show ? 0 : 30;
36384
36399
  state.inputType = convertInputType(
36385
36400
  config.interaction_inputType_mouse,
36386
36401
  config.interaction_inputType_touch
@@ -36442,7 +36457,7 @@ class ChartInternal {
36442
36457
  if (hasAxis || hasColorPatterns || hasPolar || hasTreemap || labelsBGColor || ((_a = $$.hasLegendDefsPoint) == null ? void 0 : _a.call($$))) {
36443
36458
  $el.defs = $el.svg.append("defs");
36444
36459
  if (hasAxis) {
36445
- ["id", "idXAxis", "idYAxis", "idY2Axis", "idGrid"].forEach((v) => {
36460
+ ["id", "idXAxis", "idYAxis", "idGrid"].forEach((v) => {
36446
36461
  $$.appendClip($el.defs, state.clip[v]);
36447
36462
  });
36448
36463
  }
@@ -36507,22 +36522,23 @@ class ChartInternal {
36507
36522
  if ($$.config.bar_front) {
36508
36523
  shapes.push(shapes.shift());
36509
36524
  }
36510
- shapes.forEach((v) => {
36511
- const name = capitalize(v);
36512
- if (v === "line" && $$.hasTypeOf(name) || $$.hasType(v)) {
36525
+ for (const shape2 of shapes) {
36526
+ const name = capitalize(shape2);
36527
+ if (shape2 === "line" && $$.hasTypeOf(name) || $$.hasType(shape2)) {
36513
36528
  types.push(name);
36514
36529
  }
36515
- });
36530
+ }
36516
36531
  } else if (hasTreemap) {
36517
36532
  types.push("Treemap");
36518
36533
  } else if ($$.hasType("funnel")) {
36519
36534
  types.push("Funnel");
36520
36535
  } else {
36521
36536
  const hasPolar = $$.hasType("polar");
36537
+ const hasGauge = $$.hasType("gauge");
36522
36538
  if (!hasRadar) {
36523
36539
  types.push("Arc", "Pie");
36524
36540
  }
36525
- if ($$.hasType("gauge")) {
36541
+ if (hasGauge) {
36526
36542
  types.push("Gauge");
36527
36543
  } else if (hasRadar) {
36528
36544
  types.push("Radar");
@@ -36530,10 +36546,12 @@ class ChartInternal {
36530
36546
  types.push("Polar");
36531
36547
  }
36532
36548
  }
36533
- types.forEach((v) => {
36534
- $$[`init${v}`]();
36535
- });
36536
- notEmpty($$.config.data_labels) && !$$.hasArcType(null, ["radar"]) && $$.initText();
36549
+ for (const type of types) {
36550
+ $$[`init${type}`]();
36551
+ }
36552
+ if (notEmpty($$.config.data_labels) && !$$.hasArcType(null, ["radar"])) {
36553
+ $$.initText();
36554
+ }
36537
36555
  }
36538
36556
  /**
36539
36557
  * Set chart elements
@@ -36602,7 +36620,7 @@ class ChartInternal {
36602
36620
  * @private
36603
36621
  */
36604
36622
  updateTargets(targets) {
36605
- var _a;
36623
+ var _a, _b;
36606
36624
  const $$ = this;
36607
36625
  const { hasAxis, hasFunnel, hasRadar, hasTreemap } = $$.state;
36608
36626
  const helper = (type) => $$[`updateTargetsFor${type}`](
@@ -36610,13 +36628,14 @@ class ChartInternal {
36610
36628
  );
36611
36629
  $$.updateTargetsForText(targets);
36612
36630
  if (hasAxis) {
36613
- ["bar", "candlestick", "line"].forEach((v) => {
36614
- const name = capitalize(v);
36615
- if (v === "line" && $$.hasTypeOf(name) || $$.hasType(v)) {
36631
+ const shapes = ["bar", "candlestick", "line"];
36632
+ for (const shape2 of shapes) {
36633
+ const name = capitalize(shape2);
36634
+ if (shape2 === "line" && $$.hasTypeOf(name) || $$.hasType(shape2)) {
36616
36635
  helper(name);
36617
36636
  }
36618
- });
36619
- $$.updateTargetsForSubchart && $$.updateTargetsForSubchart(targets);
36637
+ }
36638
+ (_a = $$.updateTargetsForSubchart) == null ? void 0 : _a.call($$, targets);
36620
36639
  } else if ($$.hasArcType(targets)) {
36621
36640
  let type = "Arc";
36622
36641
  if (hasRadar) {
@@ -36632,7 +36651,7 @@ class ChartInternal {
36632
36651
  }
36633
36652
  const hasPointType = $$.hasType("bubble") || $$.hasType("scatter");
36634
36653
  if (hasPointType) {
36635
- (_a = $$.updateTargetForCircle) == null ? void 0 : _a.call($$);
36654
+ (_b = $$.updateTargetForCircle) == null ? void 0 : _b.call($$);
36636
36655
  }
36637
36656
  $$.filterTargetsToShowAtInit(hasPointType);
36638
36657
  }
@@ -36666,28 +36685,25 @@ class ChartInternal {
36666
36685
  TransitionForAxis: "Transition",
36667
36686
  Y: true
36668
36687
  };
36669
- Object.keys(withOptions).forEach((key) => {
36670
- let defVal = withOptions[key];
36671
- if (isString(defVal)) {
36672
- defVal = withOptions[defVal];
36673
- }
36674
- withOptions[key] = getOption(options, `with${key}`, defVal);
36675
- });
36688
+ for (const [key, defVal] of Object.entries(withOptions)) {
36689
+ const value = isString(defVal) ? withOptions[defVal] : defVal;
36690
+ withOptions[key] = getOption(options, `with${key}`, value);
36691
+ }
36676
36692
  return withOptions;
36677
36693
  }
36678
36694
  initialOpacity(d) {
36679
36695
  const $$ = this;
36680
36696
  const { withoutFadeIn } = $$.state;
36681
- const r = $$.getBaseValue(d) !== null && withoutFadeIn[d.id] ? null : "0";
36682
- return r;
36697
+ return $$.getBaseValue(d) !== null && withoutFadeIn[d.id] ? null : "0";
36683
36698
  }
36684
36699
  bindResize() {
36685
36700
  const $$ = this;
36686
36701
  const { $el, config, state } = $$;
36687
36702
  const resizeFunction = generateResize(config.resize_timer);
36703
+ const { resize_auto } = config;
36688
36704
  const list = [];
36689
36705
  list.push(() => callFn(config.onresize, $$.api));
36690
- if (/^(true|parent)$/.test(config.resize_auto)) {
36706
+ if (/^(true|parent)$/.test(resize_auto)) {
36691
36707
  list.push(() => {
36692
36708
  state.resizing = true;
36693
36709
  if (config.legend_show) {
@@ -36703,7 +36719,7 @@ class ChartInternal {
36703
36719
  });
36704
36720
  list.forEach((v) => resizeFunction.add(v));
36705
36721
  $$.resizeFunction = resizeFunction;
36706
- if (config.resize_auto === "parent") {
36722
+ if (resize_auto === "parent") {
36707
36723
  ($$.resizeFunction.resizeObserver = new ResizeObserver($$.resizeFunction.bind($$))).observe($el.chart.node().parentNode);
36708
36724
  } else {
36709
36725
  win.addEventListener("resize", $$.resizeFunction);
@@ -44711,18 +44727,6 @@ function smoothLines(el, type) {
44711
44727
 
44712
44728
  ;// ./src/config/Options/axis/y2.ts
44713
44729
  /* harmony default export */ var y2 = ({
44714
- /**
44715
- * Set clip-path attribute for y2 axis element
44716
- * - **NOTE**: `clip-path` attribute for y2 Axis is set only when `axis.y2.inner` option is true.
44717
- * @name axis․y2․clipPath
44718
- * @memberof Options
44719
- * @type {boolean}
44720
- * @default true
44721
- * @example
44722
- * // don't set 'clip-path' attribute
44723
- * clipPath: false
44724
- */
44725
- axis_y2_clipPath: true,
44726
44730
  /**
44727
44731
  * Show or hide y2 axis.
44728
44732
  * - **NOTE**:
@@ -51043,7 +51047,7 @@ const bb = {
51043
51047
  * bb.version; // "1.0.0"
51044
51048
  * @memberof bb
51045
51049
  */
51046
- version: "3.16.0-next.2",
51050
+ version: "3.16.0",
51047
51051
  /**
51048
51052
  * Generate chart
51049
51053
  * - **NOTE:** Bear in mind for the possiblity of ***throwing an error***, during the generation when: