billboard.js 3.3.1 → 3.4.0-next.1

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 (64) hide show
  1. package/dist/billboard.css +19 -14
  2. package/dist/billboard.js +397 -74
  3. package/dist/billboard.min.css +2 -2
  4. package/dist/billboard.min.js +2 -2
  5. package/dist/billboard.pkgd.js +865 -414
  6. package/dist/billboard.pkgd.min.js +2 -2
  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 +46 -16
  10. package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
  11. package/dist/plugin/billboardjs-plugin-stanford.js +46 -16
  12. package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
  13. package/dist/plugin/billboardjs-plugin-tableview.js +41 -13
  14. package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
  15. package/dist/plugin/billboardjs-plugin-textoverlap.js +41 -13
  16. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
  17. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.js +470 -342
  18. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.js +515 -357
  19. package/dist/plugin/pkgd/billboardjs-plugin-stanford.js +516 -358
  20. package/dist/plugin/pkgd/billboardjs-plugin-tableview.js +512 -356
  21. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.js +513 -357
  22. package/dist/theme/datalab.css +24 -20
  23. package/dist/theme/datalab.min.css +2 -2
  24. package/dist/theme/graph.css +24 -20
  25. package/dist/theme/graph.min.css +2 -2
  26. package/dist/theme/insight.css +24 -20
  27. package/dist/theme/insight.min.css +2 -2
  28. package/dist-esm/billboard.js +356 -72
  29. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  30. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +3 -5
  31. package/dist-esm/plugin/billboardjs-plugin-stanford.js +3 -5
  32. package/dist-esm/plugin/billboardjs-plugin-tableview.js +2 -2
  33. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
  34. package/package.json +30 -30
  35. package/src/Chart/api/chart.ts +1 -1
  36. package/src/Chart/api/focus.ts +3 -2
  37. package/src/Chart/api/subchart.ts +8 -8
  38. package/src/ChartInternal/Axis/Axis.ts +10 -7
  39. package/src/ChartInternal/ChartInternal.ts +25 -14
  40. package/src/ChartInternal/data/data.ts +1 -1
  41. package/src/ChartInternal/internals/color.ts +4 -3
  42. package/src/ChartInternal/internals/format.ts +13 -4
  43. package/src/ChartInternal/internals/redraw.ts +6 -2
  44. package/src/ChartInternal/internals/text.ts +1 -1
  45. package/src/ChartInternal/internals/transform.ts +4 -1
  46. package/src/ChartInternal/internals/type.ts +5 -0
  47. package/src/ChartInternal/shape/arc.ts +41 -17
  48. package/src/ChartInternal/shape/polar.ts +132 -0
  49. package/src/ChartInternal/shape/radar.ts +4 -4
  50. package/src/config/Options/common/tooltip.ts +10 -1
  51. package/src/config/Options/data/data.ts +3 -0
  52. package/src/config/Options/shape/polar.ts +81 -0
  53. package/src/config/classes.ts +6 -3
  54. package/src/config/const.ts +3 -0
  55. package/src/config/resolver/shape.ts +4 -0
  56. package/src/core.ts +1 -0
  57. package/src/index.esm.ts +1 -0
  58. package/src/module/util.ts +30 -10
  59. package/src/scss/billboard.scss +13 -0
  60. package/src/scss/theme/datalab.scss +13 -0
  61. package/src/scss/theme/graph.scss +13 -0
  62. package/src/scss/theme/insight.scss +13 -0
  63. package/types/bb.d.ts +1 -0
  64. package/types/options.d.ts +72 -0
@@ -5,7 +5,7 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 3.3.1
8
+ * @version 3.4.0-next.1
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
@@ -492,17 +492,27 @@ function getBoundingRect(node) {
492
492
  /**
493
493
  * Retrun random number
494
494
  * @param {boolean} asStr Convert returned value as string
495
+ * @param {number} min Minimum value
496
+ * @param {number} max Maximum value
495
497
  * @returns {number|string}
496
498
  * @private
497
499
  */
498
500
 
499
501
 
500
- function getRandom(asStr) {
502
+ function getRandom(asStr, min, max) {
501
503
  if (asStr === void 0) {
502
504
  asStr = !0;
503
505
  }
504
506
 
505
- var rand = Math.random();
507
+ if (min === void 0) {
508
+ min = 0;
509
+ }
510
+
511
+ if (max === void 0) {
512
+ max = 1e4;
513
+ }
514
+
515
+ var rand = Math.floor(Math.random() * (max - min) + min);
506
516
  return asStr ? rand + "" : rand;
507
517
  }
508
518
  /**
@@ -976,19 +986,37 @@ function isTabVisible() {
976
986
 
977
987
 
978
988
  function convertInputType(mouse, touch) {
979
- var isMobile = !1; // https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent#Mobile_Tablet_or_Desktop
989
+ var DocumentTouch = win.DocumentTouch,
990
+ matchMedia = win.matchMedia,
991
+ navigator = win.navigator,
992
+ hasTouch = !1;
980
993
 
981
- if (/Mobi/.test(win.navigator.userAgent) && touch) {
994
+ if (touch) {
982
995
  // Some Edge desktop return true: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/20417074/
983
- var hasTouchPoints = win.navigator && "maxTouchPoints" in win.navigator && win.navigator.maxTouchPoints > 0,
984
- hasTouch = "ontouchmove" in win || win.DocumentTouch && doc instanceof win.DocumentTouch; // Ref: https://github.com/Modernizr/Modernizr/blob/master/feature-detects/touchevents.js
985
- // On IE11 with IE9 emulation mode, ('ontouchstart' in window) is returning true
996
+ if (navigator && "maxTouchPoints" in navigator) {
997
+ hasTouch = navigator.maxTouchPoints > 0; // Ref: https://github.com/Modernizr/Modernizr/blob/master/feature-detects/touchevents.js
998
+ // On IE11 with IE9 emulation mode, ('ontouchstart' in window) is returning true
999
+ } else if ("ontouchmove" in win || DocumentTouch && doc instanceof DocumentTouch) {
1000
+ hasTouch = !0;
1001
+ } else {
1002
+ // https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent#avoiding_user_agent_detection
1003
+ if (matchMedia != null && matchMedia("(pointer:coarse)").matches) {
1004
+ hasTouch = !0;
1005
+ } else {
1006
+ // Only as a last resort, fall back to user agent sniffing
1007
+ var UA = navigator.userAgent;
1008
+ hasTouch = /\b(BlackBerry|webOS|iPhone|IEMobile)\b/i.test(UA) || /\b(Android|Windows Phone|iPad|iPod)\b/i.test(UA);
1009
+ }
1010
+ }
1011
+ } // Check if agent has mouse using any-hover, touch devices (e.g iPad) with external mouse will return true as long as mouse is connected
1012
+ // https://css-tricks.com/interaction-media-features-and-their-potential-for-incorrect-assumptions/#aa-testing-the-capabilities-of-all-inputs
1013
+ // Demo: https://patrickhlauke.github.io/touch/pointer-hover-any-pointer-any-hover/
986
1014
 
987
- isMobile = hasTouchPoints || hasTouch;
988
- }
989
1015
 
990
- var hasMouse = mouse && !isMobile ? "onmouseover" in win : !1;
991
- return hasMouse && "mouse" || isMobile && "touch" || null;
1016
+ var hasMouse = mouse && ["any-hover:hover", "any-pointer:fine"].some(function (v) {
1017
+ return matchMedia == null ? void 0 : matchMedia("(" + v + ")").matches;
1018
+ });
1019
+ return hasMouse && "mouse" || hasTouch && "touch" || null;
992
1020
  }
993
1021
  ;// CONCATENATED MODULE: ./src/config/config.ts
994
1022
  /**
@@ -1113,7 +1141,7 @@ var Plugin = /*#__PURE__*/function () {
1113
1141
  return Plugin;
1114
1142
  }();
1115
1143
 
1116
- Plugin.version = "3.3.0";
1144
+ Plugin.version = "3.4.0-next.1";
1117
1145
 
1118
1146
  ;// CONCATENATED MODULE: ./src/Plugin/textoverlap/Options.ts
1119
1147
  /**
@@ -5,8 +5,8 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 3.3.1
8
+ * @version 3.4.0-next.1
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
12
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("d3-delaunay"),require("d3-polygon"),require("d3-selection"),require("d3-brush")):"function"==typeof define&&define.amd?define("bb",["d3-delaunay","d3-polygon","d3-selection","d3-brush"],t):"object"==typeof exports?exports.bb=t(require("d3-delaunay"),require("d3-polygon"),require("d3-selection"),require("d3-brush")):(e.bb=e.bb||{},e.bb.plugin=e.bb.plugin||{},e.bb.plugin.textoverlap=t(e.d3,e.d3,e.d3,e.d3))}(this,(function(e,t,n,o){return function(){"use strict";var r={3:function(e){e.exports=o},12:function(t){t.exports=e},13:function(e){e.exports=t},1:function(e){e.exports=n}},i={};function c(e){var t=i[e];if(void 0!==t)return t.exports;var n=i[e]={exports:{}};return r[e](n,n.exports,c),n.exports}c.d=function(e,t){for(var n in t)c.o(t,n)&&!c.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},c.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};var u={};return function(){function e(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function t(e,n){return t=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},t(e,n)}c.d(u,{default:function(){return d}});var n=c(12),o=c(13);c(1),c(3);var r="object"==typeof globalThis&&null!==globalThis&&globalThis.Object===Object&&globalThis||"object"==typeof global&&null!==global&&global.Object===Object&&global||"object"==typeof self&&null!==self&&self.Object===Object&&self||Function("return this")();r.requestIdleCallback=r.requestIdleCallback||function(e){return setTimeout(e,1)},r.cancelIdleCallback=r.cancelIdleCallback||function(e){return clearTimeout(e)};var i=null==r?void 0:r.document;var a=function(e){return void 0!==e},l=function(e){return"object"==typeof e};!function(){try{new MouseEvent("t")}catch(e){return function(e,t,n){void 0===n&&(n={bubbles:!1,cancelable:!1,screenX:0,screenY:0,clientX:0,clientY:0});var o=i.createEvent("MouseEvent");o.initMouseEvent(t,n.bubbles,n.cancelable,r,0,n.screenX,n.screenY,n.clientX,n.clientY,!1,!1,!1,!1,0,null),e.dispatchEvent(o)}}}();function s(e){var t,n,o,r=this.config,i=function(){var e=n.shift();return e&&t&&l(t)&&e in t?(t=t[e],i()):e?void 0:t};Object.keys(r).forEach((function(c){t=e,n=c.split("_"),o=i(),a(o)&&(r[c]=o)}))}var f=function(){function e(e){void 0===e&&(e={}),this.$$=void 0,this.options=void 0,this.options=e}var t=e.prototype;return t.$beforeInit=function(){},t.$init=function(){},t.$afterInit=function(){},t.$redraw=function(){},t.$willDestroy=function(){var e=this;Object.keys(this).forEach((function(t){e[t]=null,delete e[t]}))},e}();f.version="3.3.0";var b=function(){return{selector:void 0,extent:1,area:0}},d=function(r){var i,c;function u(t){var n=r.call(this,t)||this;return n.config=void 0,n.config=new b,e(n)||e(n)}c=r,(i=u).prototype=Object.create(c.prototype),i.prototype.constructor=i,t(i,c);var a=u.prototype;return a.$init=function(){s.call(this,this.options)},a.$redraw=function(){var e=this.$$.$el,t=this.config.selector,n=t?e.main.selectAll(t):e.text;n.empty()||this.preventLabelOverlap(n)},a.generateVoronoi=function(e){var t=this.$$.scale,o=["x","y"].map((function(e){return t[e].domain()})),r=o[0],i=o[1],c=[i[0],r[1]];return r[1]=c[0],i[0]=c[1],n.Delaunay.from(e).voronoi([].concat(r,i))},a.preventLabelOverlap=function(e){var t=this.config,n=t.extent,r=t.area,i=e.data().map((function(e){return[e.index,e.value]})),c=this.generateVoronoi(i),u=0;e.each((function(){var e=c.cellPolygon(u);if(e&&this){var t=i[u],a=t[0],l=t[1],s=(0,o.polygonCentroid)(e),f=s[0],b=s[1],d=Math.abs((0,o.polygonArea)(e)),p=Math.round(Math.atan2(b-l,f-a)/Math.PI*2),v=n*(0===p?1:-1),h=-1===p?-n:n+5,y=1===Math.abs(p)?"middle":0===p?"start":"end";this.style.display=d<r?"none":"",this.setAttribute("text-anchor",y),this.setAttribute("dy","0."+(1===p?71:35)+"em"),this.setAttribute("transform","translate("+v+", "+h+")")}u++}))},u}(f)}(),u=u.default}()}));
12
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("d3-delaunay"),require("d3-polygon"),require("d3-selection"),require("d3-brush")):"function"==typeof define&&define.amd?define("bb",["d3-delaunay","d3-polygon","d3-selection","d3-brush"],t):"object"==typeof exports?exports.bb=t(require("d3-delaunay"),require("d3-polygon"),require("d3-selection"),require("d3-brush")):(e.bb=e.bb||{},e.bb.plugin=e.bb.plugin||{},e.bb.plugin.textoverlap=t(e.d3,e.d3,e.d3,e.d3))}(this,(function(e,t,n,o){return function(){"use strict";var r={3:function(e){e.exports=o},12:function(t){t.exports=e},13:function(e){e.exports=t},1:function(e){e.exports=n}},i={};function c(e){var t=i[e];if(void 0!==t)return t.exports;var n=i[e]={exports:{}};return r[e](n,n.exports,c),n.exports}c.d=function(e,t){for(var n in t)c.o(t,n)&&!c.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},c.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};var u={};return function(){function e(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function t(e,n){return t=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},t(e,n)}c.d(u,{default:function(){return d}});var n=c(12),o=c(13);c(1),c(3);var r="object"==typeof globalThis&&null!==globalThis&&globalThis.Object===Object&&globalThis||"object"==typeof global&&null!==global&&global.Object===Object&&global||"object"==typeof self&&null!==self&&self.Object===Object&&self||Function("return this")();r.requestIdleCallback=r.requestIdleCallback||function(e){return setTimeout(e,1)},r.cancelIdleCallback=r.cancelIdleCallback||function(e){return clearTimeout(e)};var i=null==r?void 0:r.document;var a=function(e){return void 0!==e},l=function(e){return"object"==typeof e};!function(){try{new MouseEvent("t")}catch(e){return function(e,t,n){void 0===n&&(n={bubbles:!1,cancelable:!1,screenX:0,screenY:0,clientX:0,clientY:0});var o=i.createEvent("MouseEvent");o.initMouseEvent(t,n.bubbles,n.cancelable,r,0,n.screenX,n.screenY,n.clientX,n.clientY,!1,!1,!1,!1,0,null),e.dispatchEvent(o)}}}();function s(e){var t,n,o,r=this.config,i=function(){var e=n.shift();return e&&t&&l(t)&&e in t?(t=t[e],i()):e?void 0:t};Object.keys(r).forEach((function(c){t=e,n=c.split("_"),o=i(),a(o)&&(r[c]=o)}))}var f=function(){function e(e){void 0===e&&(e={}),this.$$=void 0,this.options=void 0,this.options=e}var t=e.prototype;return t.$beforeInit=function(){},t.$init=function(){},t.$afterInit=function(){},t.$redraw=function(){},t.$willDestroy=function(){var e=this;Object.keys(this).forEach((function(t){e[t]=null,delete e[t]}))},e}();f.version="3.4.0-next.1";var b=function(){return{selector:void 0,extent:1,area:0}},d=function(r){var i,c;function u(t){var n=r.call(this,t)||this;return n.config=void 0,n.config=new b,e(n)||e(n)}c=r,(i=u).prototype=Object.create(c.prototype),i.prototype.constructor=i,t(i,c);var a=u.prototype;return a.$init=function(){s.call(this,this.options)},a.$redraw=function(){var e=this.$$.$el,t=this.config.selector,n=t?e.main.selectAll(t):e.text;n.empty()||this.preventLabelOverlap(n)},a.generateVoronoi=function(e){var t=this.$$.scale,o=["x","y"].map((function(e){return t[e].domain()})),r=o[0],i=o[1],c=[i[0],r[1]];return r[1]=c[0],i[0]=c[1],n.Delaunay.from(e).voronoi([].concat(r,i))},a.preventLabelOverlap=function(e){var t=this.config,n=t.extent,r=t.area,i=e.data().map((function(e){return[e.index,e.value]})),c=this.generateVoronoi(i),u=0;e.each((function(){var e=c.cellPolygon(u);if(e&&this){var t=i[u],a=t[0],l=t[1],s=(0,o.polygonCentroid)(e),f=s[0],b=s[1],d=Math.abs((0,o.polygonArea)(e)),p=Math.round(Math.atan2(b-l,f-a)/Math.PI*2),v=n*(0===p?1:-1),h=-1===p?-n:n+5,y=1===Math.abs(p)?"middle":0===p?"start":"end";this.style.display=d<r?"none":"",this.setAttribute("text-anchor",y),this.setAttribute("dy","0."+(1===p?71:35)+"em"),this.setAttribute("transform","translate("+v+", "+h+")")}u++}))},u}(f)}(),u=u.default}()}));