cx 23.12.0 → 23.12.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/package.json
CHANGED
package/src/charts/BarGraph.js
CHANGED
|
@@ -1,33 +1,29 @@
|
|
|
1
|
-
import {Widget, VDOM} from
|
|
2
|
-
import {ColumnBarGraphBase} from
|
|
3
|
-
import {tooltipMouseMove, tooltipMouseLeave} from
|
|
4
|
-
import {isArray} from
|
|
1
|
+
import { Widget, VDOM } from "../ui/Widget";
|
|
2
|
+
import { ColumnBarGraphBase } from "./ColumnBarGraphBase";
|
|
3
|
+
import { tooltipMouseMove, tooltipMouseLeave } from "../widgets/overlay/tooltip-ops";
|
|
4
|
+
import { isArray } from "../util/isArray";
|
|
5
5
|
|
|
6
6
|
export class BarGraph extends ColumnBarGraphBase {
|
|
7
|
-
|
|
8
7
|
explore(context, instance) {
|
|
9
8
|
super.explore(context, instance);
|
|
10
9
|
|
|
11
|
-
let {data, yAxis, xAxis} = instance;
|
|
10
|
+
let { data, yAxis, xAxis } = instance;
|
|
12
11
|
|
|
13
12
|
if (isArray(data.data)) {
|
|
14
|
-
data.data.forEach(p => {
|
|
13
|
+
data.data.forEach((p) => {
|
|
15
14
|
var x0 = this.x0Field ? p[this.x0Field] : data.x0;
|
|
16
15
|
var y = p[this.yField];
|
|
17
16
|
var x = p[this.xField];
|
|
18
17
|
|
|
19
18
|
yAxis.acknowledge(y, data.size, data.offset);
|
|
20
19
|
|
|
21
|
-
if (data.autoSize)
|
|
22
|
-
yAxis.book(y, data.stacked ? data.stack : data.name);
|
|
20
|
+
if (data.autoSize) yAxis.book(y, data.stacked ? data.stack : data.name);
|
|
23
21
|
|
|
24
22
|
if (data.stacked) {
|
|
25
23
|
xAxis.stacknowledge(data.stack, y, x0);
|
|
26
24
|
xAxis.stacknowledge(data.stack, y, x);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (!this.hiddenBase)
|
|
30
|
-
xAxis.acknowledge(x0);
|
|
25
|
+
} else {
|
|
26
|
+
if (!this.hiddenBase) xAxis.acknowledge(x0);
|
|
31
27
|
xAxis.acknowledge(x);
|
|
32
28
|
}
|
|
33
29
|
});
|
|
@@ -35,16 +31,14 @@ export class BarGraph extends ColumnBarGraphBase {
|
|
|
35
31
|
}
|
|
36
32
|
|
|
37
33
|
renderGraph(context, instance) {
|
|
38
|
-
var {data, yAxis, xAxis, store} = instance;
|
|
34
|
+
var { data, yAxis, xAxis, store } = instance;
|
|
39
35
|
|
|
40
|
-
if (!isArray(data.data))
|
|
41
|
-
return false;
|
|
36
|
+
if (!isArray(data.data)) return false;
|
|
42
37
|
|
|
43
38
|
var isSelected = this.selection.getIsSelectedDelegate(store);
|
|
44
39
|
|
|
45
40
|
return data.data.map((p, i) => {
|
|
46
|
-
|
|
47
|
-
var {offset, size} = data;
|
|
41
|
+
var { offset, size } = data;
|
|
48
42
|
|
|
49
43
|
var x0 = this.x0Field ? p[this.x0Field] : data.x0;
|
|
50
44
|
var y = p[this.yField];
|
|
@@ -52,7 +46,7 @@ export class BarGraph extends ColumnBarGraphBase {
|
|
|
52
46
|
|
|
53
47
|
if (data.autoSize) {
|
|
54
48
|
var [index, count] = instance.yAxis.locate(y, data.stacked ? data.stack : data.name);
|
|
55
|
-
offset = size / count * (index - count / 2 + 0.5);
|
|
49
|
+
offset = (size / count) * (index - count / 2 + 0.5);
|
|
56
50
|
size = size / count;
|
|
57
51
|
}
|
|
58
52
|
|
|
@@ -65,47 +59,54 @@ export class BarGraph extends ColumnBarGraphBase {
|
|
|
65
59
|
var state = {
|
|
66
60
|
selected: isSelected(p, i),
|
|
67
61
|
selectable: !this.selection.isDummy,
|
|
68
|
-
[`color-${color}`]: color != null
|
|
62
|
+
[`color-${color}`]: color != null,
|
|
69
63
|
};
|
|
70
64
|
|
|
71
65
|
let mmove, mleave;
|
|
72
66
|
|
|
73
67
|
if (this.tooltip) {
|
|
74
|
-
mmove = e =>
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
68
|
+
mmove = (e) =>
|
|
69
|
+
tooltipMouseMove(e, instance, this.tooltip, {
|
|
70
|
+
target: e.target.parent,
|
|
71
|
+
data: {
|
|
72
|
+
$record: p,
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
mleave = (e) =>
|
|
76
|
+
tooltipMouseLeave(e, instance, this.tooltip, {
|
|
77
|
+
target: e.target.parent,
|
|
78
|
+
data: {
|
|
79
|
+
$record: p,
|
|
80
|
+
},
|
|
81
|
+
});
|
|
86
82
|
}
|
|
87
83
|
|
|
88
|
-
return
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
this.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
84
|
+
return (
|
|
85
|
+
<rect
|
|
86
|
+
key={i}
|
|
87
|
+
className={this.CSS.element(this.baseClass, "bar", state)}
|
|
88
|
+
onClick={(e) => {
|
|
89
|
+
this.handleClick(e, instance, p, i);
|
|
90
|
+
}}
|
|
91
|
+
x={Math.min(x1, x2)}
|
|
92
|
+
y={Math.min(y1, y2)}
|
|
93
|
+
width={Math.abs(x2 - x1)}
|
|
94
|
+
height={Math.abs(y2 - y1)}
|
|
95
|
+
style={data.style}
|
|
96
|
+
onMouseMove={mmove}
|
|
97
|
+
onMouseLeave={mleave}
|
|
98
|
+
rx={data.borderRadius}
|
|
99
|
+
/>
|
|
100
|
+
);
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
BarGraph.prototype.baseClass =
|
|
105
|
+
BarGraph.prototype.baseClass = "bargraph";
|
|
106
106
|
BarGraph.prototype.x0Field = false;
|
|
107
107
|
BarGraph.prototype.x0 = 0;
|
|
108
|
-
BarGraph.prototype.legendShape =
|
|
108
|
+
BarGraph.prototype.legendShape = "bar";
|
|
109
109
|
BarGraph.prototype.hiddenBase = false;
|
|
110
|
+
BarGraph.prototype.borderRadius = 0;
|
|
110
111
|
|
|
111
|
-
Widget.alias(
|
|
112
|
+
Widget.alias("bargraph", BarGraph);
|
|
@@ -33,6 +33,9 @@ interface ColumnBarBaseProps extends Cx.StyledContainerProps {
|
|
|
33
33
|
/** Of center offset of the column. Use this in combination with `size` to align multiple series on the same chart. */
|
|
34
34
|
offset?: Cx.NumberProp;
|
|
35
35
|
|
|
36
|
+
/** Border radius of the column/bar. */
|
|
37
|
+
borderRadius?: Cx.NumberProp;
|
|
38
|
+
|
|
36
39
|
/**
|
|
37
40
|
* Name of the horizontal axis. The value should match one of the horizontal axes set
|
|
38
41
|
* in the `axes` configuration of the parent `Chart` component. Default value is `x`.
|
|
@@ -29,6 +29,7 @@ export class ColumnBarBase extends PureContainer {
|
|
|
29
29
|
stack: undefined,
|
|
30
30
|
offset: undefined,
|
|
31
31
|
hoverId: undefined,
|
|
32
|
+
borderRadius: undefined,
|
|
32
33
|
});
|
|
33
34
|
}
|
|
34
35
|
|
|
@@ -126,6 +127,7 @@ export class ColumnBarBase extends PureContainer {
|
|
|
126
127
|
y={bounds.t}
|
|
127
128
|
width={Math.max(0.0001, bounds.width())}
|
|
128
129
|
height={Math.max(0.0001, bounds.height())}
|
|
130
|
+
rx={data.borderRadius}
|
|
129
131
|
onMouseMove={(e) => {
|
|
130
132
|
onMouseMove(e, instance);
|
|
131
133
|
tooltipMouseMove(e, instance, this.tooltip);
|
|
@@ -167,3 +169,4 @@ ColumnBarBase.prototype.stack = "stack";
|
|
|
167
169
|
ColumnBarBase.prototype.legendShape = "rect";
|
|
168
170
|
ColumnBarBase.prototype.styled = true;
|
|
169
171
|
ColumnBarBase.prototype.hoverChannel = "default";
|
|
172
|
+
ColumnBarBase.prototype.borderRadius = 0;
|
|
@@ -1,72 +1,73 @@
|
|
|
1
|
-
import * as Cx from
|
|
2
|
-
import { KeySelection, PropertySelection } from
|
|
1
|
+
import * as Cx from "../core";
|
|
2
|
+
import { KeySelection, PropertySelection } from "../ui/selection";
|
|
3
3
|
|
|
4
4
|
interface ColumnBarGraphBaseProps extends Cx.WidgetProps {
|
|
5
|
-
|
|
6
|
-
/**
|
|
5
|
+
/**
|
|
7
6
|
* Data for the graph. Each entry should be an object with at least two properties
|
|
8
7
|
* whose names should match the `xField` and `yField` values.
|
|
9
8
|
*/
|
|
10
|
-
data?: Cx.RecordsProp
|
|
9
|
+
data?: Cx.RecordsProp;
|
|
11
10
|
|
|
12
11
|
/** Index of a color from the standard palette of colors. 0-15. */
|
|
13
|
-
colorIndex?: Cx.NumberProp
|
|
12
|
+
colorIndex?: Cx.NumberProp;
|
|
14
13
|
|
|
15
14
|
/** Used to automatically assign a color based on the `name` and the contextual `ColorMap` widget. */
|
|
16
|
-
colorMap?: Cx.StringProp
|
|
15
|
+
colorMap?: Cx.StringProp;
|
|
17
16
|
|
|
18
17
|
/** Name used to resolve the color. If not provided, `name` is used instead. */
|
|
19
|
-
colorName?: Cx.StringProp
|
|
18
|
+
colorName?: Cx.StringProp;
|
|
20
19
|
|
|
21
20
|
/** Name of the item as it will appear in the legend. */
|
|
22
|
-
name?: Cx.StringProp
|
|
21
|
+
name?: Cx.StringProp;
|
|
23
22
|
|
|
24
23
|
/** Size (width) of the column in axis units. */
|
|
25
|
-
size?: Cx.NumberProp
|
|
24
|
+
size?: Cx.NumberProp;
|
|
26
25
|
|
|
27
26
|
/** Of center offset of the column. Use this in combination with `size` to align multiple series on the same chart. */
|
|
28
|
-
offset?: Cx.NumberProp
|
|
27
|
+
offset?: Cx.NumberProp;
|
|
29
28
|
|
|
30
29
|
/** Set to true to auto-calculate size and offset. Available only if the x axis is a category axis. */
|
|
31
|
-
autoSize?: Cx.BooleanProp
|
|
30
|
+
autoSize?: Cx.BooleanProp;
|
|
32
31
|
|
|
33
32
|
/** Used to indicate if an item is active or not. Inactive items are shown only in the legend. */
|
|
34
|
-
active?: Cx.BooleanProp
|
|
33
|
+
active?: Cx.BooleanProp;
|
|
35
34
|
|
|
36
35
|
/** Indicate that columns should be stacked on top of the other columns. Default value is `false`. */
|
|
37
|
-
stacked?: Cx.BooleanProp
|
|
36
|
+
stacked?: Cx.BooleanProp;
|
|
37
|
+
|
|
38
|
+
/** Border radius of the column/bar. */
|
|
39
|
+
borderRadius?: Cx.NumberProp;
|
|
38
40
|
|
|
39
41
|
/** Name of the stack. If multiple stacks are used, each should have a unique name. Default value is `stack`. */
|
|
40
|
-
stack?: Cx.StringProp
|
|
41
|
-
|
|
42
|
+
stack?: Cx.StringProp;
|
|
43
|
+
|
|
42
44
|
/** Name of the horizontal axis. The value should match one of the horizontal axes set
|
|
43
45
|
* in the `axes` configuration of the parent `Chart` component. Default value is `x`.
|
|
44
46
|
*/
|
|
45
|
-
xAxis?: string
|
|
47
|
+
xAxis?: string;
|
|
46
48
|
|
|
47
49
|
/**
|
|
48
|
-
* Name of the vertical axis. The value should match one of the vertical axes set
|
|
50
|
+
* Name of the vertical axis. The value should match one of the vertical axes set
|
|
49
51
|
* in the `axes` configuration if the parent `Chart` component. Default value is `y`.
|
|
50
52
|
*/
|
|
51
|
-
yAxis?: string
|
|
53
|
+
yAxis?: string;
|
|
52
54
|
|
|
53
55
|
/** Name of the property which holds the x value. Default value is `x`. */
|
|
54
|
-
xField?: string
|
|
56
|
+
xField?: string;
|
|
55
57
|
|
|
56
58
|
/** Name of the property which holds the y value. Default value is `y`. */
|
|
57
|
-
yField?: string
|
|
59
|
+
yField?: string;
|
|
58
60
|
|
|
59
|
-
colorIndexField?: boolean
|
|
61
|
+
colorIndexField?: boolean;
|
|
60
62
|
|
|
61
63
|
/** Name of the legend to be used. Default is `legend`. */
|
|
62
|
-
legend?: string
|
|
64
|
+
legend?: string;
|
|
63
65
|
|
|
64
|
-
legendAction?: string
|
|
65
|
-
legendShape?: string
|
|
66
|
+
legendAction?: string;
|
|
67
|
+
legendShape?: string;
|
|
66
68
|
|
|
67
69
|
/** Selection configuration. */
|
|
68
|
-
selection?: { type: typeof PropertySelection | typeof KeySelection
|
|
69
|
-
|
|
70
|
+
selection?: { type: typeof PropertySelection | typeof KeySelection; [prop: string]: any };
|
|
70
71
|
}
|
|
71
72
|
|
|
72
|
-
export class ColumnBarGraphBase extends Cx.Widget<ColumnBarGraphBaseProps> {}
|
|
73
|
+
export class ColumnBarGraphBase extends Cx.Widget<ColumnBarGraphBaseProps> {}
|
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
import {Widget, VDOM} from
|
|
2
|
-
import {Selection} from
|
|
1
|
+
import { Widget, VDOM } from "../ui/Widget";
|
|
2
|
+
import { Selection } from "../ui/selection/Selection";
|
|
3
3
|
|
|
4
4
|
export class ColumnBarGraphBase extends Widget {
|
|
5
|
-
|
|
6
5
|
init() {
|
|
7
6
|
this.selection = Selection.create(this.selection, {
|
|
8
|
-
records: this.data
|
|
7
|
+
records: this.data,
|
|
9
8
|
});
|
|
10
9
|
super.init();
|
|
11
10
|
}
|
|
12
11
|
|
|
13
12
|
declareData() {
|
|
14
|
-
|
|
15
13
|
var selection = this.selection.configureWidget(this);
|
|
16
14
|
|
|
17
15
|
super.declareData(selection, ...arguments, {
|
|
@@ -27,15 +25,15 @@ export class ColumnBarGraphBase extends Widget {
|
|
|
27
25
|
autoSize: undefined,
|
|
28
26
|
active: true,
|
|
29
27
|
stacked: undefined,
|
|
30
|
-
stack: undefined
|
|
31
|
-
|
|
28
|
+
stack: undefined,
|
|
29
|
+
borderRadius: undefined,
|
|
30
|
+
});
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
prepareData(context, instance) {
|
|
35
|
-
let {data} = instance;
|
|
34
|
+
let { data } = instance;
|
|
36
35
|
|
|
37
|
-
if (data.name && !data.colorName)
|
|
38
|
-
data.colorName = data.name;
|
|
36
|
+
if (data.name && !data.colorName) data.colorName = data.name;
|
|
39
37
|
|
|
40
38
|
super.prepareData(context, instance);
|
|
41
39
|
}
|
|
@@ -44,28 +42,23 @@ export class ColumnBarGraphBase extends Widget {
|
|
|
44
42
|
instance.xAxis = context.axes[this.xAxis];
|
|
45
43
|
instance.yAxis = context.axes[this.yAxis];
|
|
46
44
|
|
|
47
|
-
var {data} = instance;
|
|
45
|
+
var { data } = instance;
|
|
48
46
|
|
|
49
47
|
instance.colorMap = data.colorMap && context.getColorMap && context.getColorMap(data.colorMap);
|
|
50
|
-
if (instance.colorMap && data.colorName)
|
|
51
|
-
instance.colorMap.acknowledge(data.colorName);
|
|
48
|
+
if (instance.colorMap && data.colorName) instance.colorMap.acknowledge(data.colorName);
|
|
52
49
|
|
|
53
50
|
super.explore(context, instance);
|
|
54
51
|
}
|
|
55
52
|
|
|
56
53
|
prepare(context, instance) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
let {data, colorMap, xAxis, yAxis} = instance;
|
|
54
|
+
let { data, colorMap, xAxis, yAxis } = instance;
|
|
60
55
|
|
|
61
56
|
if (colorMap && data.name) {
|
|
62
57
|
data.colorIndex = colorMap.map(data.colorName);
|
|
63
|
-
if (instance.cache(
|
|
64
|
-
instance.markShouldUpdate(context);
|
|
58
|
+
if (instance.cache("colorIndex", data.colorIndex)) instance.markShouldUpdate(context);
|
|
65
59
|
}
|
|
66
60
|
|
|
67
|
-
if (xAxis.shouldUpdate || yAxis.shouldUpdate)
|
|
68
|
-
instance.markShouldUpdate(context);
|
|
61
|
+
if (xAxis.shouldUpdate || yAxis.shouldUpdate) instance.markShouldUpdate(context);
|
|
69
62
|
|
|
70
63
|
if (data.name && context.addLegendEntry)
|
|
71
64
|
context.addLegendEntry(this.legend, {
|
|
@@ -76,44 +69,46 @@ export class ColumnBarGraphBase extends Widget {
|
|
|
76
69
|
selected: this.selection.isInstanceSelected(instance),
|
|
77
70
|
style: data.style,
|
|
78
71
|
shape: this.legendShape,
|
|
79
|
-
onClick: e=> {
|
|
72
|
+
onClick: (e) => {
|
|
73
|
+
this.onLegendClick(e, instance);
|
|
74
|
+
},
|
|
80
75
|
});
|
|
81
76
|
}
|
|
82
77
|
|
|
83
78
|
onLegendClick(e, instance) {
|
|
84
|
-
var allActions = this.legendAction ==
|
|
85
|
-
var {data} = instance;
|
|
86
|
-
if (allActions || this.legendAction ==
|
|
87
|
-
instance.set('active', !data.active);
|
|
79
|
+
var allActions = this.legendAction == "auto";
|
|
80
|
+
var { data } = instance;
|
|
81
|
+
if (allActions || this.legendAction == "toggle") instance.set("active", !data.active);
|
|
88
82
|
}
|
|
89
83
|
|
|
90
84
|
render(context, instance, key) {
|
|
91
|
-
var {data} = instance;
|
|
92
|
-
return
|
|
93
|
-
{data.
|
|
94
|
-
|
|
85
|
+
var { data } = instance;
|
|
86
|
+
return (
|
|
87
|
+
<g key={key} className={data.classNames}>
|
|
88
|
+
{data.active && this.renderGraph(context, instance)}
|
|
89
|
+
</g>
|
|
90
|
+
);
|
|
95
91
|
}
|
|
96
92
|
|
|
97
93
|
handleClick(e, instance, point, index) {
|
|
98
|
-
if (this.onClick && instance.invoke("onClick", e, instance, point, index) === false)
|
|
99
|
-
return;
|
|
94
|
+
if (this.onClick && instance.invoke("onClick", e, instance, point, index) === false) return;
|
|
100
95
|
|
|
101
|
-
if (!this.selection.isDummy)
|
|
102
|
-
this.selection.select(instance.store, point, index, { toggle: e.ctrlKey });
|
|
96
|
+
if (!this.selection.isDummy) this.selection.select(instance.store, point, index, { toggle: e.ctrlKey });
|
|
103
97
|
}
|
|
104
98
|
}
|
|
105
99
|
|
|
106
|
-
ColumnBarGraphBase.prototype.xAxis =
|
|
107
|
-
ColumnBarGraphBase.prototype.yAxis =
|
|
108
|
-
ColumnBarGraphBase.prototype.xField =
|
|
109
|
-
ColumnBarGraphBase.prototype.yField =
|
|
100
|
+
ColumnBarGraphBase.prototype.xAxis = "x";
|
|
101
|
+
ColumnBarGraphBase.prototype.yAxis = "y";
|
|
102
|
+
ColumnBarGraphBase.prototype.xField = "x";
|
|
103
|
+
ColumnBarGraphBase.prototype.yField = "y";
|
|
110
104
|
ColumnBarGraphBase.prototype.colorIndexField = false;
|
|
111
105
|
ColumnBarGraphBase.prototype.size = 1;
|
|
112
|
-
ColumnBarGraphBase.prototype.legend =
|
|
113
|
-
ColumnBarGraphBase.prototype.legendAction =
|
|
114
|
-
ColumnBarGraphBase.prototype.legendShape =
|
|
115
|
-
ColumnBarGraphBase.prototype.stack =
|
|
106
|
+
ColumnBarGraphBase.prototype.legend = "legend";
|
|
107
|
+
ColumnBarGraphBase.prototype.legendAction = "auto";
|
|
108
|
+
ColumnBarGraphBase.prototype.legendShape = "rect";
|
|
109
|
+
ColumnBarGraphBase.prototype.stack = "stack";
|
|
116
110
|
ColumnBarGraphBase.prototype.stacked = false;
|
|
117
111
|
ColumnBarGraphBase.prototype.autoSize = 0;
|
|
118
112
|
ColumnBarGraphBase.prototype.offset = 0;
|
|
119
113
|
ColumnBarGraphBase.prototype.styled = true;
|
|
114
|
+
ColumnBarGraphBase.prototype.borderRadius = 0;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import {Widget, VDOM} from
|
|
2
|
-
import {ColumnBarGraphBase} from
|
|
3
|
-
import {tooltipMouseMove, tooltipMouseLeave} from
|
|
4
|
-
import {isArray} from
|
|
1
|
+
import { Widget, VDOM } from "../ui/Widget";
|
|
2
|
+
import { ColumnBarGraphBase } from "./ColumnBarGraphBase";
|
|
3
|
+
import { tooltipMouseMove, tooltipMouseLeave } from "../widgets/overlay/tooltip-ops";
|
|
4
|
+
import { isArray } from "../util/isArray";
|
|
5
5
|
|
|
6
6
|
export class ColumnGraph extends ColumnBarGraphBase {
|
|
7
|
-
|
|
8
7
|
explore(context, instance) {
|
|
9
8
|
super.explore(context, instance);
|
|
10
9
|
|
|
11
|
-
let {data, xAxis, yAxis} = instance;
|
|
10
|
+
let { data, xAxis, yAxis } = instance;
|
|
12
11
|
|
|
13
12
|
if (isArray(data.data)) {
|
|
14
13
|
data.data.forEach((p, index) => {
|
|
@@ -18,36 +17,29 @@ export class ColumnGraph extends ColumnBarGraphBase {
|
|
|
18
17
|
|
|
19
18
|
xAxis.acknowledge(x, data.size, data.offset);
|
|
20
19
|
|
|
21
|
-
if (data.autoSize)
|
|
22
|
-
xAxis.book(x, data.stacked ? data.stack : data.name);
|
|
20
|
+
if (data.autoSize) xAxis.book(x, data.stacked ? data.stack : data.name);
|
|
23
21
|
|
|
24
22
|
if (data.stacked) {
|
|
25
23
|
yAxis.stacknowledge(data.stack, x, y0);
|
|
26
24
|
yAxis.stacknowledge(data.stack, x, y);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (!this.hiddenBase)
|
|
30
|
-
yAxis.acknowledge(y0);
|
|
25
|
+
} else {
|
|
26
|
+
if (!this.hiddenBase) yAxis.acknowledge(y0);
|
|
31
27
|
yAxis.acknowledge(y);
|
|
32
28
|
}
|
|
33
29
|
|
|
34
|
-
if (context.pointReducer)
|
|
35
|
-
context.pointReducer(x, y, data.name, p, data, index);
|
|
30
|
+
if (context.pointReducer) context.pointReducer(x, y, data.name, p, data, index);
|
|
36
31
|
});
|
|
37
32
|
}
|
|
38
33
|
}
|
|
39
34
|
|
|
40
35
|
renderGraph(context, instance) {
|
|
41
|
-
var {data, xAxis, yAxis, store} = instance;
|
|
42
|
-
|
|
43
|
-
if (!isArray(data.data))
|
|
44
|
-
return false;
|
|
36
|
+
var { data, xAxis, yAxis, store } = instance;
|
|
37
|
+
if (!isArray(data.data)) return false;
|
|
45
38
|
|
|
46
39
|
var isSelected = this.selection.getIsSelectedDelegate(store);
|
|
47
40
|
|
|
48
41
|
return data.data.map((p, i) => {
|
|
49
|
-
|
|
50
|
-
var {offset, size} = data;
|
|
42
|
+
var { offset, size } = data;
|
|
51
43
|
|
|
52
44
|
var y0 = this.y0Field ? p[this.y0Field] : data.y0;
|
|
53
45
|
var x = p[this.xField];
|
|
@@ -55,7 +47,7 @@ export class ColumnGraph extends ColumnBarGraphBase {
|
|
|
55
47
|
|
|
56
48
|
if (data.autoSize) {
|
|
57
49
|
var [index, count] = instance.xAxis.locate(x, data.stacked ? data.stack : data.name);
|
|
58
|
-
offset = size / count * (index - count / 2 + 0.5);
|
|
50
|
+
offset = (size / count) * (index - count / 2 + 0.5);
|
|
59
51
|
size = size / count;
|
|
60
52
|
}
|
|
61
53
|
|
|
@@ -68,48 +60,53 @@ export class ColumnGraph extends ColumnBarGraphBase {
|
|
|
68
60
|
var state = {
|
|
69
61
|
selected: isSelected(p, i),
|
|
70
62
|
selectable: !this.selection.isDummy,
|
|
71
|
-
[`color-${color}`]: color != null
|
|
63
|
+
[`color-${color}`]: color != null,
|
|
72
64
|
};
|
|
73
65
|
|
|
74
66
|
let mmove, mleave;
|
|
75
67
|
|
|
76
68
|
if (this.tooltip) {
|
|
77
|
-
mmove = e =>
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
69
|
+
mmove = (e) =>
|
|
70
|
+
tooltipMouseMove(e, instance, this.tooltip, {
|
|
71
|
+
target: e.target.parent,
|
|
72
|
+
data: {
|
|
73
|
+
$record: p,
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
mleave = (e) =>
|
|
77
|
+
tooltipMouseLeave(e, instance, this.tooltip, {
|
|
78
|
+
target: e.target.parent,
|
|
79
|
+
data: {
|
|
80
|
+
$record: p,
|
|
81
|
+
},
|
|
82
|
+
});
|
|
89
83
|
}
|
|
90
84
|
|
|
91
|
-
return
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
85
|
+
return (
|
|
86
|
+
<rect
|
|
87
|
+
key={i}
|
|
88
|
+
className={this.CSS.element(this.baseClass, "column", state)}
|
|
89
|
+
onClick={(e) => {
|
|
90
|
+
this.handleClick(e, instance, p, i);
|
|
91
|
+
}}
|
|
92
|
+
x={Math.min(x1, x2)}
|
|
93
|
+
y={Math.min(y1, y2)}
|
|
94
|
+
width={Math.abs(x2 - x1)}
|
|
95
|
+
height={Math.abs(y2 - y1)}
|
|
96
|
+
style={data.style}
|
|
97
|
+
onMouseMove={mmove}
|
|
98
|
+
onMouseLeave={mleave}
|
|
99
|
+
rx={data.borderRadius}
|
|
100
|
+
/>
|
|
101
|
+
);
|
|
105
102
|
});
|
|
106
103
|
}
|
|
107
104
|
}
|
|
108
105
|
|
|
109
|
-
ColumnGraph.prototype.baseClass =
|
|
106
|
+
ColumnGraph.prototype.baseClass = "columngraph";
|
|
110
107
|
ColumnGraph.prototype.y0Field = false;
|
|
111
108
|
ColumnGraph.prototype.y0 = 0;
|
|
112
|
-
ColumnGraph.prototype.legendShape =
|
|
109
|
+
ColumnGraph.prototype.legendShape = "column";
|
|
113
110
|
ColumnGraph.prototype.hiddenBase = false;
|
|
114
111
|
|
|
115
|
-
Widget.alias(
|
|
112
|
+
Widget.alias("columngraph", ColumnGraph);
|