billboard.js 3.2.2 → 3.3.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.
- package/dist/billboard.css +1 -1
- package/dist/billboard.js +818 -468
- package/dist/billboard.min.css +1 -1
- package/dist/billboard.min.js +2 -2
- package/dist/billboard.pkgd.js +4765 -3104
- package/dist/billboard.pkgd.min.js +4 -4
- package/dist/plugin/billboardjs-plugin-bubblecompare.d.ts +7 -0
- package/dist/plugin/billboardjs-plugin-bubblecompare.js +2 -2
- package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-sparkline.d.ts +7 -0
- package/dist/plugin/billboardjs-plugin-sparkline.js +145 -99
- package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-stanford.d.ts +7 -0
- package/dist/plugin/billboardjs-plugin-stanford.js +144 -98
- package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-tableview.d.ts +7 -0
- package/dist/plugin/billboardjs-plugin-tableview.js +13 -128
- package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-textoverlap.d.ts +7 -0
- package/dist/plugin/billboardjs-plugin-textoverlap.js +11 -126
- package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.js +3980 -2669
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.js +4119 -2762
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.js +4117 -2760
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.js +3970 -2774
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.js +3969 -2773
- package/dist/theme/datalab.css +1 -1
- package/dist/theme/datalab.min.css +2 -2
- package/dist/theme/graph.css +1 -1
- package/dist/theme/graph.min.css +2 -2
- package/dist/theme/insight.css +1 -1
- package/dist/theme/insight.min.css +2 -2
- package/dist-esm/billboard.js +787 -464
- package/dist-esm/plugin/billboardjs-plugin-bubblecompare.d.ts +7 -0
- package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -4
- package/dist-esm/plugin/billboardjs-plugin-sparkline.d.ts +7 -0
- package/dist-esm/plugin/billboardjs-plugin-sparkline.js +131 -79
- package/dist-esm/plugin/billboardjs-plugin-stanford.d.ts +7 -0
- package/dist-esm/plugin/billboardjs-plugin-stanford.js +135 -80
- package/dist-esm/plugin/billboardjs-plugin-tableview.d.ts +7 -0
- package/dist-esm/plugin/billboardjs-plugin-tableview.js +4 -8
- package/dist-esm/plugin/billboardjs-plugin-textoverlap.d.ts +7 -0
- package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +4 -7
- package/package.json +45 -44
- package/src/Chart/api/chart.ts +7 -1
- package/src/Chart/api/data.ts +3 -4
- package/src/Chart/api/focus.ts +8 -8
- package/src/Chart/api/regions.ts +3 -3
- package/src/Chart/api/selection.ts +15 -15
- package/src/Chart/api/subchart.ts +3 -3
- package/src/ChartInternal/Axis/Axis.ts +26 -19
- package/src/ChartInternal/ChartInternal.ts +18 -8
- package/src/ChartInternal/data/IData.ts +9 -0
- package/src/ChartInternal/data/convert.ts +1 -1
- package/src/ChartInternal/data/data.ts +29 -12
- package/src/ChartInternal/data/load.ts +2 -2
- package/src/ChartInternal/interactions/drag.ts +15 -15
- package/src/ChartInternal/interactions/eventrect.ts +18 -18
- package/src/ChartInternal/interactions/interaction.ts +46 -14
- package/src/ChartInternal/interactions/zoom.ts +4 -4
- package/src/ChartInternal/internals/color.ts +4 -4
- package/src/ChartInternal/internals/domain.ts +5 -3
- package/src/ChartInternal/internals/grid.ts +32 -32
- package/src/ChartInternal/internals/legend.ts +27 -27
- package/src/ChartInternal/internals/redraw.ts +3 -3
- package/src/ChartInternal/internals/region.ts +3 -3
- package/src/ChartInternal/internals/scale.ts +3 -2
- package/src/ChartInternal/internals/selection.ts +16 -15
- package/src/ChartInternal/internals/size.ts +35 -4
- package/src/ChartInternal/internals/text.ts +10 -10
- package/src/ChartInternal/internals/title.ts +4 -4
- package/src/ChartInternal/internals/tooltip.ts +9 -6
- package/src/ChartInternal/internals/transform.ts +5 -5
- package/src/ChartInternal/shape/arc.ts +24 -22
- package/src/ChartInternal/shape/area.ts +4 -4
- package/src/ChartInternal/shape/bar.ts +87 -40
- package/src/ChartInternal/shape/candlestick.ts +8 -8
- package/src/ChartInternal/shape/gauge.ts +8 -8
- package/src/ChartInternal/shape/line.ts +7 -7
- package/src/ChartInternal/shape/point.ts +18 -18
- package/src/ChartInternal/shape/radar.ts +12 -10
- package/src/ChartInternal/shape/shape.ts +76 -13
- package/src/Plugin/sparkline/index.ts +4 -4
- package/src/Plugin/stanford/index.ts +3 -3
- package/src/Plugin/stanford/util.ts +0 -1
- package/src/Plugin/tableview/index.ts +1 -1
- package/src/config/Options/axis/x.ts +27 -7
- package/src/config/Options/axis/y.ts +24 -3
- package/src/config/Options/axis/y2.ts +24 -3
- package/src/config/Options/common/main.ts +11 -1
- package/src/config/Options/data/data.ts +22 -0
- package/src/config/Options/shape/bar.ts +9 -2
- package/src/config/classes.ts +154 -66
- package/src/module/util.ts +17 -17
- package/types/axis.d.ts +22 -8
- package/types/chart.d.ts +1 -1
- package/types/options.d.ts +40 -33
- package/types/plugin/tableview/index.d.ts +3 -3
- package/types/plugin/tableview/options.d.ts +1 -1
- package/types/types.d.ts +4 -4
package/src/Chart/api/focus.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* billboard.js project is licensed under the MIT license
|
|
4
4
|
*/
|
|
5
5
|
import {select as d3Select} from "d3-selection";
|
|
6
|
-
import
|
|
6
|
+
import {$FOCUS, $GAUGE} from "../../config/classes";
|
|
7
7
|
|
|
8
8
|
type FocusParam = string | string[];
|
|
9
9
|
|
|
@@ -36,13 +36,13 @@ export default {
|
|
|
36
36
|
this.revert();
|
|
37
37
|
this.defocus();
|
|
38
38
|
|
|
39
|
-
candidates.classed(
|
|
39
|
+
candidates.classed($FOCUS.focused, true).classed($FOCUS.defocused, false);
|
|
40
40
|
|
|
41
41
|
if ($$.hasArcType() && !state.hasRadar) {
|
|
42
42
|
$$.expandArc(targetIds);
|
|
43
43
|
|
|
44
44
|
$$.hasType("gauge") &&
|
|
45
|
-
$$.markOverlapped(targetIdsValue, $$, `.${
|
|
45
|
+
$$.markOverlapped(targetIdsValue, $$, `.${$GAUGE.gaugeValue}`);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
$$.toggleFocusLegend(targetIds, true);
|
|
@@ -76,13 +76,13 @@ export default {
|
|
|
76
76
|
$$.selectorTargets(targetIds.filter($$.isTargetToShow, $$))
|
|
77
77
|
);
|
|
78
78
|
|
|
79
|
-
candidates.classed(
|
|
79
|
+
candidates.classed($FOCUS.focused, false).classed($FOCUS.defocused, true);
|
|
80
80
|
|
|
81
81
|
if ($$.hasArcType()) {
|
|
82
82
|
$$.unexpandArc(targetIds);
|
|
83
83
|
|
|
84
84
|
$$.hasType("gauge") &&
|
|
85
|
-
$$.undoMarkOverlapped($$, `.${
|
|
85
|
+
$$.undoMarkOverlapped($$, `.${$GAUGE.gaugeValue}`);
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
$$.toggleFocusLegend(targetIds, false);
|
|
@@ -114,16 +114,16 @@ export default {
|
|
|
114
114
|
const targetIds = $$.mapToTargetIds(targetIdsValue);
|
|
115
115
|
const candidates = $el.svg.selectAll($$.selectorTargets(targetIds)); // should be for all targets
|
|
116
116
|
|
|
117
|
-
candidates.classed(
|
|
117
|
+
candidates.classed($FOCUS.focused, false).classed($FOCUS.defocused, false);
|
|
118
118
|
$$.hasArcType() && $$.unexpandArc(targetIds);
|
|
119
119
|
|
|
120
120
|
if (config.legend_show) {
|
|
121
121
|
$$.showLegend(targetIds.filter($$.isLegendToShow.bind($$)));
|
|
122
122
|
$el.legend.selectAll($$.selectorLegends(targetIds))
|
|
123
123
|
.filter(function() {
|
|
124
|
-
return d3Select(this).classed(
|
|
124
|
+
return d3Select(this).classed($FOCUS.legendItemFocused);
|
|
125
125
|
})
|
|
126
|
-
.classed(
|
|
126
|
+
.classed($FOCUS.legendItemFocused, false);
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
state.focusedTargetIds = [];
|
package/src/Chart/api/regions.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
3
3
|
* billboard.js project is licensed under the MIT license
|
|
4
4
|
*/
|
|
5
|
-
import
|
|
5
|
+
import {$REGION} from "../../config/classes";
|
|
6
6
|
import {getOption, extend} from "../../module/util";
|
|
7
7
|
|
|
8
8
|
type RegionsParam = {axis?: string, class?: string, start?: number, end?: number}[];
|
|
@@ -94,8 +94,8 @@ extend(regions, {
|
|
|
94
94
|
const {config, $T} = $$;
|
|
95
95
|
|
|
96
96
|
const options = optionsValue || {};
|
|
97
|
-
const classes = getOption(options, "classes", [
|
|
98
|
-
let regions = $$.$el.main.select(`.${
|
|
97
|
+
const classes = getOption(options, "classes", [$REGION.region]);
|
|
98
|
+
let regions = $$.$el.main.select(`.${$REGION.regions}`)
|
|
99
99
|
.selectAll(classes.map(c => `.${c}`));
|
|
100
100
|
|
|
101
101
|
$T(regions)
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import {select as d3Select} from "d3-selection";
|
|
6
6
|
import {isDefined} from "../../module/util";
|
|
7
|
-
import
|
|
7
|
+
import {$AREA, $LINE, $SELECT, $SHAPE} from "../../config/classes";
|
|
8
8
|
import {DataItem} from "../../../types/types";
|
|
9
9
|
|
|
10
10
|
export default {
|
|
@@ -28,10 +28,10 @@ export default {
|
|
|
28
28
|
const $$ = this.internal;
|
|
29
29
|
const dataPoint: DataItem[] = [];
|
|
30
30
|
|
|
31
|
-
$$.$el.main.selectAll(`.${
|
|
32
|
-
.selectAll(`.${
|
|
31
|
+
$$.$el.main.selectAll(`.${$SHAPE.shapes + $$.getTargetSelectorSuffix(targetId)}`)
|
|
32
|
+
.selectAll(`.${$SHAPE.shape}`)
|
|
33
33
|
.filter(function() {
|
|
34
|
-
return d3Select(this).classed(
|
|
34
|
+
return d3Select(this).classed($SELECT.SELECTED);
|
|
35
35
|
})
|
|
36
36
|
.each(d => dataPoint.push(d));
|
|
37
37
|
|
|
@@ -70,27 +70,27 @@ export default {
|
|
|
70
70
|
return;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
$el.main.selectAll(`.${
|
|
74
|
-
.selectAll(`.${
|
|
73
|
+
$el.main.selectAll(`.${$SHAPE.shapes}`)
|
|
74
|
+
.selectAll(`.${$SHAPE.shape}`)
|
|
75
75
|
.each(function(d, i) {
|
|
76
76
|
const shape = d3Select(this);
|
|
77
77
|
const id = d.data ? d.data.id : d.id;
|
|
78
78
|
const toggle = $$.getToggle(this, d).bind($$);
|
|
79
79
|
const isTargetId = config.data_selection_grouped || !ids || ids.indexOf(id) >= 0;
|
|
80
80
|
const isTargetIndex = !indices || indices.indexOf(i) >= 0;
|
|
81
|
-
const isSelected = shape.classed(
|
|
81
|
+
const isSelected = shape.classed($SELECT.SELECTED);
|
|
82
82
|
|
|
83
83
|
// line/area selection not supported yet
|
|
84
|
-
if (shape.classed(
|
|
84
|
+
if (shape.classed($LINE.line) || shape.classed($AREA.area)) {
|
|
85
85
|
return;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
if (isTargetId && isTargetIndex) {
|
|
89
89
|
if (config.data_selection_isselectable.bind($$.api)(d) && !isSelected) {
|
|
90
|
-
toggle(true, shape.classed(
|
|
90
|
+
toggle(true, shape.classed($SELECT.SELECTED, true), d, i);
|
|
91
91
|
}
|
|
92
92
|
} else if (isDefined(resetOther) && resetOther && isSelected) {
|
|
93
|
-
toggle(false, shape.classed(
|
|
93
|
+
toggle(false, shape.classed($SELECT.SELECTED, false), d, i);
|
|
94
94
|
}
|
|
95
95
|
});
|
|
96
96
|
},
|
|
@@ -120,18 +120,18 @@ export default {
|
|
|
120
120
|
return;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
$el.main.selectAll(`.${
|
|
124
|
-
.selectAll(`.${
|
|
123
|
+
$el.main.selectAll(`.${$SHAPE.shapes}`)
|
|
124
|
+
.selectAll(`.${$SHAPE.shape}`)
|
|
125
125
|
.each(function(d, i) {
|
|
126
126
|
const shape = d3Select(this);
|
|
127
127
|
const id = d.data ? d.data.id : d.id;
|
|
128
128
|
const toggle = $$.getToggle(this, d).bind($$);
|
|
129
129
|
const isTargetId = config.data_selection_grouped || !ids || ids.indexOf(id) >= 0;
|
|
130
130
|
const isTargetIndex = !indices || indices.indexOf(i) >= 0;
|
|
131
|
-
const isSelected = shape.classed(
|
|
131
|
+
const isSelected = shape.classed($SELECT.SELECTED);
|
|
132
132
|
|
|
133
133
|
// line/area selection not supported yet
|
|
134
|
-
if (shape.classed(
|
|
134
|
+
if (shape.classed($LINE.line) || shape.classed($AREA.area)) {
|
|
135
135
|
return;
|
|
136
136
|
}
|
|
137
137
|
|
|
@@ -140,7 +140,7 @@ export default {
|
|
|
140
140
|
config.data_selection_isselectable.bind($$.api)(d) &&
|
|
141
141
|
isSelected
|
|
142
142
|
) {
|
|
143
|
-
toggle(false, shape.classed(
|
|
143
|
+
toggle(false, shape.classed($SELECT.SELECTED, false), d, i);
|
|
144
144
|
}
|
|
145
145
|
});
|
|
146
146
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
3
3
|
* billboard.js project is licensed under the MIT license
|
|
4
4
|
*/
|
|
5
|
-
import
|
|
5
|
+
import {$COMMON} from "../../config/classes";
|
|
6
6
|
|
|
7
7
|
export default {
|
|
8
8
|
subchart: {
|
|
@@ -41,14 +41,14 @@ export default {
|
|
|
41
41
|
config.subchart_show = !show;
|
|
42
42
|
!subchart.main && $$.initSubchart();
|
|
43
43
|
|
|
44
|
-
let $target = subchart.main.selectAll(`.${
|
|
44
|
+
let $target = subchart.main.selectAll(`.${$COMMON.target}`);
|
|
45
45
|
|
|
46
46
|
// need to cover when new data has been loaded
|
|
47
47
|
if ($$.data.targets.length !== $target.size()) {
|
|
48
48
|
$$.updateSizes();
|
|
49
49
|
$$.updateTargetsForSubchart($$.data.targets);
|
|
50
50
|
|
|
51
|
-
$target = subchart.main.selectAll(`.${
|
|
51
|
+
$target = subchart.main.selectAll(`.${$COMMON.target}`);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
$target.style("opacity", null);
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from "d3-axis";
|
|
11
11
|
import AxisRenderer from "./AxisRenderer";
|
|
12
12
|
import {getScale} from "../internals/scale";
|
|
13
|
-
import
|
|
13
|
+
import {$AXIS} from "../../config/classes";
|
|
14
14
|
import {capitalize, isArray, isFunction, isString, isValue, isEmpty, isNumber, isObjectType, mergeObj, notEmpty, parseDate, sortValue} from "../../module/util";
|
|
15
15
|
|
|
16
16
|
export default {
|
|
@@ -45,7 +45,7 @@ class Axis {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
private getAxisClassName(id) {
|
|
48
|
-
return `${
|
|
48
|
+
return `${$AXIS.axis} ${$AXIS[`axis${capitalize(id)}`]}`;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
private isHorizontal($$, forHorizontal) {
|
|
@@ -100,7 +100,7 @@ class Axis {
|
|
|
100
100
|
|
|
101
101
|
target.forEach(v => {
|
|
102
102
|
const classAxis = this.getAxisClassName(v);
|
|
103
|
-
const classLabel =
|
|
103
|
+
const classLabel = $AXIS[`axis${v.toUpperCase()}Label`];
|
|
104
104
|
|
|
105
105
|
axis[v] = main.append("g")
|
|
106
106
|
.attr("class", classAxis)
|
|
@@ -197,7 +197,7 @@ class Axis {
|
|
|
197
197
|
*/
|
|
198
198
|
updateAxes() {
|
|
199
199
|
const $$ = this.owner;
|
|
200
|
-
const {config, $el: {main}} = $$;
|
|
200
|
+
const {config, $el: {main}, $T} = $$;
|
|
201
201
|
|
|
202
202
|
Object.keys(this.axesList).forEach(id => {
|
|
203
203
|
const axesConfig = config[`axis_${id}_axes`];
|
|
@@ -224,7 +224,7 @@ class Axis {
|
|
|
224
224
|
} else {
|
|
225
225
|
axesConfig[i].domain && scale.domain(axesConfig[i].domain);
|
|
226
226
|
|
|
227
|
-
|
|
227
|
+
$T(g).call(v.scale(scale));
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
g.attr("transform", $$.getTranslate(id, i + 1));
|
|
@@ -739,9 +739,9 @@ class Axis {
|
|
|
739
739
|
const {$el: {main}, $T} = $$;
|
|
740
740
|
|
|
741
741
|
const labels = {
|
|
742
|
-
x: main.select(`.${
|
|
743
|
-
y: main.select(`.${
|
|
744
|
-
y2: main.select(`.${
|
|
742
|
+
x: main.select(`.${$AXIS.axisX} .${$AXIS.axisXLabel}`),
|
|
743
|
+
y: main.select(`.${$AXIS.axisY} .${$AXIS.axisYLabel}`),
|
|
744
|
+
y2: main.select(`.${$AXIS.axisY2} .${$AXIS.axisY2Label}`)
|
|
745
745
|
};
|
|
746
746
|
|
|
747
747
|
Object.keys(labels).filter(id => !labels[id].empty())
|
|
@@ -891,11 +891,12 @@ class Axis {
|
|
|
891
891
|
}
|
|
892
892
|
|
|
893
893
|
["y", "y2"].forEach(key => {
|
|
894
|
+
const prefix = `axis_${key}_`;
|
|
894
895
|
const axisScale = scale[key];
|
|
895
896
|
|
|
896
|
-
if (axisScale) {
|
|
897
|
-
const tickValues = config[
|
|
898
|
-
const tickCount = config[
|
|
897
|
+
if (config[`${prefix}show`] && axisScale) {
|
|
898
|
+
const tickValues = config[`${prefix}tick_values`];
|
|
899
|
+
const tickCount = config[`${prefix}tick_count`];
|
|
899
900
|
|
|
900
901
|
axisScale.domain($$.getYDomain(targetsToShow, key, xDomainForZoom));
|
|
901
902
|
|
|
@@ -945,13 +946,16 @@ class Axis {
|
|
|
945
946
|
|
|
946
947
|
// subchart x axis should be aligned with x axis culling
|
|
947
948
|
const id = type === "subX" ? "x" : type;
|
|
948
|
-
|
|
949
|
+
|
|
950
|
+
const cullingOptionPrefix = `axis_${id}_tick_culling`;
|
|
951
|
+
const toCull = config[cullingOptionPrefix];
|
|
949
952
|
|
|
950
953
|
if (axis && toCull) {
|
|
951
|
-
const
|
|
952
|
-
const tickValues = sortValue(
|
|
954
|
+
const tickNodes = axis.selectAll(".tick");
|
|
955
|
+
const tickValues = sortValue(tickNodes.data());
|
|
953
956
|
const tickSize = tickValues.length;
|
|
954
|
-
const cullingMax = config[
|
|
957
|
+
const cullingMax = config[`${cullingOptionPrefix}_max`];
|
|
958
|
+
const lines = config[`${cullingOptionPrefix}_lines`];
|
|
955
959
|
let intervalForCulling;
|
|
956
960
|
|
|
957
961
|
if (tickSize) {
|
|
@@ -962,18 +966,21 @@ class Axis {
|
|
|
962
966
|
}
|
|
963
967
|
}
|
|
964
968
|
|
|
965
|
-
|
|
966
|
-
|
|
969
|
+
tickNodes.each(function(d) {
|
|
970
|
+
if (tickValues.indexOf(d) % intervalForCulling) {
|
|
971
|
+
(lines ? this.querySelector("text") : this)
|
|
972
|
+
.style.display = "none";
|
|
973
|
+
}
|
|
967
974
|
});
|
|
968
975
|
} else {
|
|
969
|
-
|
|
976
|
+
tickNodes.style("display", null);
|
|
970
977
|
}
|
|
971
978
|
|
|
972
979
|
// set/unset x_axis_tick_clippath
|
|
973
980
|
if (type === "x") {
|
|
974
981
|
const clipPath = current.maxTickWidths.x.clipPath ? clip.pathXAxisTickTexts : null;
|
|
975
982
|
|
|
976
|
-
$el.svg.selectAll(`.${
|
|
983
|
+
$el.svg.selectAll(`.${$AXIS.axisX} .tick text`)
|
|
977
984
|
.attr("clip-path", clipPath);
|
|
978
985
|
}
|
|
979
986
|
}
|
|
@@ -12,8 +12,7 @@ import {
|
|
|
12
12
|
import {select as d3Select} from "d3-selection";
|
|
13
13
|
import {d3Selection} from "../../types/types";
|
|
14
14
|
import {checkModuleImport} from "../module/error";
|
|
15
|
-
|
|
16
|
-
import CLASS from "../config/classes";
|
|
15
|
+
import {$COMMON, $TEXT} from "../config/classes";
|
|
17
16
|
import Store from "../config/Store/Store";
|
|
18
17
|
import Options from "../config/Options/Options";
|
|
19
18
|
import {document, window} from "../module/browser";
|
|
@@ -182,6 +181,14 @@ export default class ChartInternal {
|
|
|
182
181
|
state.hasAxis = !$$.hasArcType();
|
|
183
182
|
state.hasRadar = !state.hasAxis && $$.hasType("radar");
|
|
184
183
|
|
|
184
|
+
// when 'padding=false' is set, disable axes and subchart. Because they are useless.
|
|
185
|
+
if (config.padding === false) {
|
|
186
|
+
config.axis_x_show = false;
|
|
187
|
+
config.axis_y_show = false;
|
|
188
|
+
config.axis_y2_show = false;
|
|
189
|
+
config.subchart_show = false;
|
|
190
|
+
}
|
|
191
|
+
|
|
185
192
|
$$.initParams();
|
|
186
193
|
|
|
187
194
|
const bindto = {
|
|
@@ -202,7 +209,9 @@ export default class ChartInternal {
|
|
|
202
209
|
$el.chart = d3Select(document.body.appendChild(document.createElement("div")));
|
|
203
210
|
}
|
|
204
211
|
|
|
205
|
-
$el.chart.html("")
|
|
212
|
+
$el.chart.html("")
|
|
213
|
+
.classed(bindto.classname, true)
|
|
214
|
+
.style("position", "relative");
|
|
206
215
|
|
|
207
216
|
$$.initToRender();
|
|
208
217
|
}
|
|
@@ -290,7 +299,8 @@ export default class ChartInternal {
|
|
|
290
299
|
state.isLegendLeft = config.legend_inset_anchor === "top-left" ||
|
|
291
300
|
config.legend_inset_anchor === "bottom-left";
|
|
292
301
|
|
|
293
|
-
state.
|
|
302
|
+
state.rotatedPadding.top = $$.getResettedPadding(state.rotatedPadding.top);
|
|
303
|
+
state.rotatedPadding.right = isRotated && !config.axis_x_show ? 0 : 30;
|
|
294
304
|
|
|
295
305
|
state.inputType = convertInputType(
|
|
296
306
|
config.interaction_inputType_mouse,
|
|
@@ -402,7 +412,7 @@ export default class ChartInternal {
|
|
|
402
412
|
|
|
403
413
|
// Define regions
|
|
404
414
|
const main = $el.svg.append("g")
|
|
405
|
-
.classed(
|
|
415
|
+
.classed($COMMON.main, true)
|
|
406
416
|
.attr("transform", $$.getTranslate("main"));
|
|
407
417
|
|
|
408
418
|
$el.main = main;
|
|
@@ -419,7 +429,7 @@ export default class ChartInternal {
|
|
|
419
429
|
// text when empty
|
|
420
430
|
if (config.data_empty_label_text) {
|
|
421
431
|
main.append("text")
|
|
422
|
-
.attr("class", `${
|
|
432
|
+
.attr("class", `${$TEXT.text} ${$COMMON.empty}`)
|
|
423
433
|
.attr("text-anchor", "middle") // horizontal centering of text at x position in all browsers.
|
|
424
434
|
.attr("dominant-baseline", "middle"); // vertical centering of text at y position in all browsers, except IE.
|
|
425
435
|
}
|
|
@@ -433,7 +443,7 @@ export default class ChartInternal {
|
|
|
433
443
|
}
|
|
434
444
|
|
|
435
445
|
// Define g for chart area
|
|
436
|
-
main.append("g").attr("class",
|
|
446
|
+
main.append("g").attr("class", $COMMON.chart)
|
|
437
447
|
.attr("clip-path", state.clip.path);
|
|
438
448
|
|
|
439
449
|
$$.callPluginHook("$init");
|
|
@@ -634,7 +644,7 @@ export default class ChartInternal {
|
|
|
634
644
|
const $$ = <any> this;
|
|
635
645
|
const {$el: {svg}, $T} = $$;
|
|
636
646
|
|
|
637
|
-
$T(svg.selectAll(`.${
|
|
647
|
+
$T(svg.selectAll(`.${$COMMON.target}`)
|
|
638
648
|
.filter(d => $$.isTargetToShow(d.id))
|
|
639
649
|
).style("opacity", null);
|
|
640
650
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
3
3
|
* billboard.js project is licensed under the MIT license
|
|
4
4
|
*/
|
|
5
|
-
import
|
|
5
|
+
import {$BAR, $CANDLESTICK, $COMMON} from "../../config/classes";
|
|
6
6
|
import {KEY} from "../../module/Cache";
|
|
7
7
|
import {IData, IDataRow} from "./IData";
|
|
8
8
|
import {
|
|
@@ -82,7 +82,7 @@ export default {
|
|
|
82
82
|
* @returns {number} index number
|
|
83
83
|
* @private
|
|
84
84
|
*/
|
|
85
|
-
getIndexByX(x, basedX: (string
|
|
85
|
+
getIndexByX(x: Date|number|string, basedX: (Date|number|string)[]): number {
|
|
86
86
|
const $$ = this;
|
|
87
87
|
|
|
88
88
|
return basedX ?
|
|
@@ -154,7 +154,7 @@ export default {
|
|
|
154
154
|
.map(t => $$.addName($$.getValueOnIndex(t.values, index)));
|
|
155
155
|
|
|
156
156
|
if (filterNull) {
|
|
157
|
-
value = value.filter(v => isValue(v.value));
|
|
157
|
+
value = value.filter(v => v && "value" in v && isValue(v.value));
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
return value;
|
|
@@ -586,6 +586,7 @@ export default {
|
|
|
586
586
|
|
|
587
587
|
/**
|
|
588
588
|
* Sort targets data
|
|
589
|
+
* Note: For stacked bar, will sort from the total sum of data series, not for each stacked bar
|
|
589
590
|
* @param {Array} targetsValue Target value
|
|
590
591
|
* @returns {Array}
|
|
591
592
|
* @private
|
|
@@ -617,9 +618,9 @@ export default {
|
|
|
617
618
|
if (orderAsc || orderDesc) {
|
|
618
619
|
const reducer = (p, c) => p + Math.abs(c.value);
|
|
619
620
|
|
|
620
|
-
fn = (t1, t2) => {
|
|
621
|
-
const t1Sum = t1.values.reduce(reducer, 0);
|
|
622
|
-
const t2Sum = t2.values.reduce(reducer, 0);
|
|
621
|
+
fn = (t1: IData | IDataRow, t2: IData | IDataRow) => {
|
|
622
|
+
const t1Sum = "values" in t1 ? t1.values.reduce(reducer, 0) : t1.value;
|
|
623
|
+
const t2Sum = "values" in t2 ? t2.values.reduce(reducer, 0) : t2.value;
|
|
623
624
|
|
|
624
625
|
return isArc ?
|
|
625
626
|
(orderAsc ? t1Sum - t2Sum : t2Sum - t1Sum) :
|
|
@@ -743,20 +744,23 @@ export default {
|
|
|
743
744
|
let minDist = config.point_sensitivity;
|
|
744
745
|
let closest;
|
|
745
746
|
|
|
746
|
-
// find mouseovering bar
|
|
747
|
+
// find mouseovering bar/candlestick
|
|
748
|
+
// https://github.com/naver/billboard.js/issues/2434
|
|
747
749
|
data
|
|
748
|
-
.filter(v => $$.isBarType(v.id))
|
|
750
|
+
.filter(v => $$.isBarType(v.id) || $$.isCandlestickType(v.id))
|
|
749
751
|
.forEach(v => {
|
|
750
|
-
const
|
|
752
|
+
const selector = $$.isBarType(v.id) ?
|
|
753
|
+
`.${$BAR.chartBar}.${$COMMON.target}${$$.getTargetSelectorSuffix(v.id)} .${$BAR.bar}-${v.index}` :
|
|
754
|
+
`.${$CANDLESTICK.chartCandlestick}.${$COMMON.target}${$$.getTargetSelectorSuffix(v.id)} .${$CANDLESTICK.candlestick}-${v.index} path`;
|
|
751
755
|
|
|
752
|
-
if (!closest && $$.isWithinBar(
|
|
756
|
+
if (!closest && $$.isWithinBar(main.select(selector).node())) {
|
|
753
757
|
closest = v;
|
|
754
758
|
}
|
|
755
759
|
});
|
|
756
760
|
|
|
757
|
-
// find closest point from non-bar
|
|
761
|
+
// find closest point from non-bar/candlestick
|
|
758
762
|
data
|
|
759
|
-
.filter(v => !$$.isBarType(v.id))
|
|
763
|
+
.filter(v => !$$.isBarType(v.id) && !$$.isCandlestickType(v.id))
|
|
760
764
|
.forEach(v => {
|
|
761
765
|
const d = $$.dist(v, pos);
|
|
762
766
|
|
|
@@ -983,6 +987,19 @@ export default {
|
|
|
983
987
|
);
|
|
984
988
|
},
|
|
985
989
|
|
|
990
|
+
/**
|
|
991
|
+
* Determine if bar has ranged data
|
|
992
|
+
* @param {Array} d data value
|
|
993
|
+
* @returns {boolean}
|
|
994
|
+
* @private
|
|
995
|
+
*/
|
|
996
|
+
isBarRangeType(d): boolean {
|
|
997
|
+
const $$ = this;
|
|
998
|
+
const {value} = d;
|
|
999
|
+
|
|
1000
|
+
return $$.isBarType(d) && isArray(value) && value.length === 2 && value.every(v => isNumber(v));
|
|
1001
|
+
},
|
|
1002
|
+
|
|
986
1003
|
/**
|
|
987
1004
|
* Get data object by id
|
|
988
1005
|
* @param {string} id data id
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
3
3
|
* billboard.js project is licensed under the MIT license
|
|
4
4
|
*/
|
|
5
|
-
import
|
|
5
|
+
import {$LEGEND} from "../../config/classes";
|
|
6
6
|
import {endall} from "../../module/util";
|
|
7
7
|
|
|
8
8
|
export default {
|
|
@@ -111,7 +111,7 @@ export default {
|
|
|
111
111
|
|
|
112
112
|
// Remove target's elements
|
|
113
113
|
if ($el.legend) {
|
|
114
|
-
$el.legend.selectAll(`.${
|
|
114
|
+
$el.legend.selectAll(`.${$LEGEND.legendItem}${$$.getTargetSelectorSuffix(id)}`).remove();
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
// Remove target
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import {select as d3Select} from "d3-selection";
|
|
6
6
|
import {d3Selection} from "../../../types/types";
|
|
7
|
-
import
|
|
7
|
+
import {$BAR, $CIRCLE, $COMMON, $DRAG, $SELECT, $SHAPE} from "../../config/classes";
|
|
8
8
|
import {getPathBox} from "../../module/util";
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -39,30 +39,30 @@ export default {
|
|
|
39
39
|
const minY = isSelectionGrouped ? state.margin.top : Math.min(sy, my);
|
|
40
40
|
const maxY = isSelectionGrouped ? state.height : Math.max(sy, my);
|
|
41
41
|
|
|
42
|
-
main.select(`.${
|
|
42
|
+
main.select(`.${$DRAG.dragarea}`)
|
|
43
43
|
.attr("x", minX)
|
|
44
44
|
.attr("y", minY)
|
|
45
45
|
.attr("width", maxX - minX)
|
|
46
46
|
.attr("height", maxY - minY);
|
|
47
47
|
|
|
48
48
|
// TODO: binary search when multiple xs
|
|
49
|
-
main.selectAll(`.${
|
|
50
|
-
.selectAll(`.${
|
|
49
|
+
main.selectAll(`.${$SHAPE.shapes}`)
|
|
50
|
+
.selectAll(`.${$SHAPE.shape}`)
|
|
51
51
|
.filter(d => isSelectable?.bind($$.api)(d))
|
|
52
52
|
.each(function(d, i) {
|
|
53
53
|
const shape: d3Selection = d3Select(this);
|
|
54
|
-
const isSelected = shape.classed(
|
|
55
|
-
const isIncluded = shape.classed(
|
|
54
|
+
const isSelected = shape.classed($SELECT.SELECTED);
|
|
55
|
+
const isIncluded = shape.classed($DRAG.INCLUDED);
|
|
56
56
|
let isWithin: any = false;
|
|
57
57
|
let toggle;
|
|
58
58
|
|
|
59
|
-
if (shape.classed(
|
|
59
|
+
if (shape.classed($CIRCLE.circle)) {
|
|
60
60
|
const x: number = +shape.attr("cx") * 1;
|
|
61
61
|
const y: number = +shape.attr("cy") * 1;
|
|
62
62
|
|
|
63
63
|
toggle = $$.togglePoint;
|
|
64
64
|
isWithin = minX < x && x < maxX && minY < y && y < maxY;
|
|
65
|
-
} else if (shape.classed(
|
|
65
|
+
} else if (shape.classed($BAR.bar)) {
|
|
66
66
|
const {x, y, width, height} = getPathBox(this);
|
|
67
67
|
|
|
68
68
|
toggle = $$.togglePath;
|
|
@@ -74,9 +74,9 @@ export default {
|
|
|
74
74
|
|
|
75
75
|
// @ts-ignore
|
|
76
76
|
if (isWithin ^ isIncluded) {
|
|
77
|
-
shape.classed(
|
|
77
|
+
shape.classed($DRAG.INCLUDED, !isIncluded);
|
|
78
78
|
// TODO: included/unincluded callback here
|
|
79
|
-
shape.classed(
|
|
79
|
+
shape.classed($SELECT.SELECTED, !isSelected);
|
|
80
80
|
toggle.call($$, !isSelected, shape, d, i);
|
|
81
81
|
}
|
|
82
82
|
});
|
|
@@ -98,9 +98,9 @@ export default {
|
|
|
98
98
|
|
|
99
99
|
state.dragStart = mouse;
|
|
100
100
|
|
|
101
|
-
main.select(`.${
|
|
101
|
+
main.select(`.${$COMMON.chart}`)
|
|
102
102
|
.append("rect")
|
|
103
|
-
.attr("class",
|
|
103
|
+
.attr("class", $DRAG.dragarea)
|
|
104
104
|
.style("opacity", "0.1");
|
|
105
105
|
|
|
106
106
|
$$.setDragStatus(true);
|
|
@@ -119,12 +119,12 @@ export default {
|
|
|
119
119
|
return;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
$T(main.select(`.${
|
|
122
|
+
$T(main.select(`.${$DRAG.dragarea}`))
|
|
123
123
|
.style("opacity", "0")
|
|
124
124
|
.remove();
|
|
125
125
|
|
|
126
|
-
main.selectAll(`.${
|
|
127
|
-
.classed(
|
|
126
|
+
main.selectAll(`.${$SHAPE.shape}`)
|
|
127
|
+
.classed($DRAG.INCLUDED, false);
|
|
128
128
|
|
|
129
129
|
$$.setDragStatus(false);
|
|
130
130
|
}
|