billboard.js 3.2.2 → 3.3.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 (52) hide show
  1. package/dist/billboard.css +1 -1
  2. package/dist/billboard.js +230 -68
  3. package/dist/billboard.min.css +1 -1
  4. package/dist/billboard.min.js +2 -2
  5. package/dist/billboard.pkgd.js +3196 -1856
  6. package/dist/billboard.pkgd.min.js +3 -3
  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 +10 -9
  10. package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
  11. package/dist/plugin/billboardjs-plugin-stanford.js +10 -9
  12. package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
  13. package/dist/plugin/billboardjs-plugin-tableview.js +12 -11
  14. package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
  15. package/dist/plugin/billboardjs-plugin-textoverlap.js +10 -9
  16. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
  17. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.js +2976 -1798
  18. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.js +2985 -1806
  19. package/dist/plugin/pkgd/billboardjs-plugin-stanford.js +2986 -1807
  20. package/dist/plugin/pkgd/billboardjs-plugin-tableview.js +3045 -1866
  21. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.js +3045 -1866
  22. package/dist/theme/datalab.css +1 -1
  23. package/dist/theme/datalab.min.css +1 -1
  24. package/dist/theme/graph.css +1 -1
  25. package/dist/theme/graph.min.css +1 -1
  26. package/dist/theme/insight.css +1 -1
  27. package/dist/theme/insight.min.css +1 -1
  28. package/dist-esm/billboard.js +198 -55
  29. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  30. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +2 -2
  31. package/dist-esm/plugin/billboardjs-plugin-stanford.js +2 -2
  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 +29 -29
  35. package/src/ChartInternal/ChartInternal.ts +10 -1
  36. package/src/ChartInternal/data/convert.ts +1 -1
  37. package/src/ChartInternal/data/data.ts +27 -10
  38. package/src/ChartInternal/internals/domain.ts +4 -2
  39. package/src/ChartInternal/internals/scale.ts +3 -2
  40. package/src/ChartInternal/internals/size.ts +32 -1
  41. package/src/ChartInternal/internals/text.ts +2 -2
  42. package/src/ChartInternal/internals/tooltip.ts +4 -0
  43. package/src/ChartInternal/shape/bar.ts +78 -33
  44. package/src/ChartInternal/shape/shape.ts +33 -2
  45. package/src/Plugin/tableview/index.ts +1 -1
  46. package/src/config/Options/axis/x.ts +2 -2
  47. package/src/config/Options/common/main.ts +11 -1
  48. package/src/config/Options/data/data.ts +22 -0
  49. package/src/config/Options/shape/bar.ts +1 -2
  50. package/src/module/util.ts +16 -15
  51. package/types/options.d.ts +8 -1
  52. package/types/types.d.ts +4 -4
@@ -262,8 +262,8 @@ export default {
262
262
 
263
263
  /**
264
264
  * Fit x axis ticks.
265
- * - **true**: ticks will be positioned nicely to have same intervals.
266
- * - **false**: ticks will be positioned according to x value of the data points.
265
+ * - **true**: ticks will be shown according to x value of the data points.
266
+ * - **false**: ticks will be shown as to have same intervals.
267
267
  * @name axis․x․tick․fit
268
268
  * @memberof Options
269
269
  * @type {boolean}
@@ -109,12 +109,21 @@ export default {
109
109
  * @name padding
110
110
  * @memberof Options
111
111
  * @type {object}
112
- * @property {object} [padding] padding object
112
+ * @property {object|boolean} [padding=true] Set padding of chart, and accepts object or boolean type.
113
+ * - `Object`: Specify each side's padding.
114
+ * - `false`: Remove padding completely and make shape to fully occupy the container element.
115
+ * - In this case, axes and subchart will be hidden.
116
+ * - To adjust some padding from this state, use `axis.[x|y].padding` option.
113
117
  * @property {number} [padding.top] padding on the top of chart
114
118
  * @property {number} [padding.right] padding on the right of chart
115
119
  * @property {number} [padding.bottom] padding on the bottom of chart
116
120
  * @property {number} [padding.left] padding on the left of chart
121
+ * @see [Demo](https://naver.github.io/billboard.js/demo/#ChartOptions.Padding)
117
122
  * @example
123
+ * // remove padding completely.
124
+ * padding: false,
125
+ *
126
+ * // or specify padding value for each side
118
127
  * padding: {
119
128
  * top: 20,
120
129
  * right: 20,
@@ -122,6 +131,7 @@ export default {
122
131
  * left: 20
123
132
  * }
124
133
  */
134
+ padding: true,
125
135
  padding_left: <number|undefined> undefined,
126
136
  padding_right: <number|undefined> undefined,
127
137
  padding_top: <number|undefined> undefined,
@@ -634,6 +634,18 @@ export default {
634
634
  * ]
635
635
  * }
636
636
  *
637
+ * // for 'bar' type, data can contain:
638
+ * // - an array of [start, end] data following the order
639
+ * data: {
640
+ * rows: [
641
+ * ["data1", "data2"],
642
+ * [[100, 150], 120],
643
+ * [[200, 300], 55],
644
+ * [[-400, 500], 60]
645
+ * ],
646
+ * type: "bar"
647
+ * }
648
+ *
637
649
  * // for 'range' types('area-line-range' or 'area-spline-range'), data should contain:
638
650
  * // - an array of [high, mid, low] data following the order
639
651
  * // - or an object with 'high', 'mid' and 'low' key value
@@ -710,6 +722,16 @@ export default {
710
722
  * ]
711
723
  * }
712
724
  *
725
+ * // for 'bar' type, data can contain:
726
+ * // - an array of [start, end] data following the order
727
+ * data: {
728
+ * columns: [
729
+ * ["data1", -100, 50, [100, 200], [200, 300]],
730
+ * ["data2", -200, 300, [-100, 100], [-50, -30]],
731
+ * ],
732
+ * type: "bar"
733
+ * }
734
+ *
713
735
  * // for 'range' types('area-line-range' or 'area-spline-range'), data should contain:
714
736
  * // - an array of [high, mid, low] data following the order
715
737
  * // - or an object with 'high', 'mid' and 'low' key value
@@ -15,7 +15,6 @@ export default {
15
15
  * @property {number} [bar.label.threshold=0] Set threshold ratio to show/hide labels.
16
16
  * @property {number} [bar.padding=0] The padding pixel value between each bar.
17
17
  * @property {number} [bar.radius] Set the radius of bar edge in pixel.
18
- * - **NOTE:** Works only for non-stacked bar
19
18
  * @property {number} [bar.radius.ratio] Set the radius ratio of bar edge in relative the bar's width.
20
19
  * @property {number} [bar.sensitivity=2] The senstivity offset value for interaction boundary.
21
20
  * @property {number} [bar.width] Change the width of bar chart.
@@ -36,7 +35,7 @@ export default {
36
35
  * bar: {
37
36
  * padding: 1,
38
37
  *
39
- * // the 'radius' option can be used only for non-stacking bars
38
+ * // bar radius
40
39
  * radius: 10,
41
40
  * // or
42
41
  * radius: {
@@ -60,23 +60,23 @@ export {
60
60
  };
61
61
 
62
62
  const isValue = (v: any): boolean => v || v === 0;
63
- const isFunction = (v: any): boolean => typeof v === "function";
64
- const isString = (v: any): boolean => typeof v === "string";
65
- const isNumber = (v: any): boolean => typeof v === "number";
66
- const isUndefined = (v: any): boolean => typeof v === "undefined";
67
- const isDefined = (v: any): boolean => typeof v !== "undefined";
68
- const isboolean = (v: any): boolean => typeof v === "boolean";
69
- const ceil10 = (v: any): number => Math.ceil(v / 10) * 10;
70
- const asHalfPixel = (n: any): number => Math.ceil(n) + 0.5;
63
+ const isFunction = (v: unknown): v is ((...args: any[]) => any) => typeof v === "function";
64
+ const isString = (v: unknown): v is string => typeof v === "string";
65
+ const isNumber = (v: unknown): v is number => typeof v === "number";
66
+ const isUndefined = (v: unknown): v is undefined => typeof v === "undefined";
67
+ const isDefined = (v: unknown): boolean => typeof v !== "undefined";
68
+ const isboolean = (v: unknown): boolean => typeof v === "boolean";
69
+ const ceil10 = (v: number): number => Math.ceil(v / 10) * 10;
70
+ const asHalfPixel = (n: number): number => Math.ceil(n) + 0.5;
71
71
  const diffDomain = (d: number[]): number => d[1] - d[0];
72
- const isObjectType = (v: any): boolean => typeof v === "object";
73
- const isEmpty = (o: any): boolean => (
72
+ const isObjectType = (v: unknown): v is Record<string | number, any> => typeof v === "object";
73
+ const isEmpty = (o: unknown): boolean => (
74
74
  isUndefined(o) || o === null ||
75
75
  (isString(o) && o.length === 0) ||
76
76
  (isObjectType(o) && !(o instanceof Date) && Object.keys(o).length === 0) ||
77
77
  (isNumber(o) && isNaN(o))
78
78
  );
79
- const notEmpty = (o: any): boolean => !isEmpty(o);
79
+ const notEmpty = (o: unknown): boolean => !isEmpty(o);
80
80
 
81
81
  /**
82
82
  * Check if is array
@@ -84,7 +84,7 @@ const notEmpty = (o: any): boolean => !isEmpty(o);
84
84
  * @returns {boolean}
85
85
  * @private
86
86
  */
87
- const isArray = (arr: any): boolean => Array.isArray(arr);
87
+ const isArray = (arr: any): arr is any[] => Array.isArray(arr);
88
88
 
89
89
  /**
90
90
  * Check if is object
@@ -125,14 +125,15 @@ function hasValue(dict: object, value: any): boolean {
125
125
  /**
126
126
  * Call function with arguments
127
127
  * @param {Function} fn Function to be called
128
- * @param {*} args Arguments
128
+ * @param {*} thisArg "this" value for fn
129
+ * @param {*} args Arguments for fn
129
130
  * @returns {boolean} true: fn is function, false: fn is not function
130
131
  * @private
131
132
  */
132
- function callFn(fn, ...args): boolean {
133
+ function callFn(fn: unknown, thisArg: any, ...args: any[]): boolean {
133
134
  const isFn = isFunction(fn);
134
135
 
135
- isFn && fn.call(...args);
136
+ isFn && fn.call(thisArg, ...args);
136
137
  return isFn;
137
138
  }
138
139
 
@@ -64,7 +64,14 @@ export interface ChartOptions {
64
64
  height?: number;
65
65
  };
66
66
 
67
- padding?: {
67
+ /**
68
+ * Set padding of chart, and accepts object or boolean type.
69
+ * - `Object`: Specify each side's padding.
70
+ * - `false`: Remove padding completely and make shape to fully occupy the container element.
71
+ * - In this case, axes and subchart will be hidden.
72
+ * - To adjust some padding from this state, use `axis.[x|y].padding` option.
73
+ */
74
+ padding?: boolean | {
68
75
  /**
69
76
  * The padding on the top of the chart.
70
77
  */
package/types/types.d.ts CHANGED
@@ -34,16 +34,16 @@ export interface TargetIds {
34
34
  ids: string[] | string;
35
35
  }
36
36
 
37
- export interface DataRow {
37
+ export interface DataRow<T=number> {
38
38
  id: string;
39
39
  id_org: string; // eslint-disable-line camelcase
40
- values: DataItem[];
40
+ values: Array<DataItem<T>>;
41
41
  }
42
42
 
43
- export interface DataItem {
43
+ export interface DataItem<T=number> {
44
44
  id: string;
45
45
  x: number;
46
- value: number;
46
+ value: T;
47
47
  index?: number;
48
48
  name?: string;
49
49
  ratio?: number;