cx 23.12.0 → 23.12.2
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 +1 -1
- package/src/charts/BarGraph.js +49 -48
- package/src/charts/ColumnBarBase.d.ts +3 -0
- package/src/charts/ColumnBarBase.js +3 -0
- package/src/charts/ColumnBarGraphBase.d.ts +29 -28
- package/src/charts/ColumnBarGraphBase.js +36 -41
- package/src/charts/ColumnGraph.js +48 -51
- package/src/data/AggregateFunction.d.ts +20 -20
- package/src/data/AggregateFunction.js +145 -145
- package/src/widgets/form/MonthField.d.ts +6 -1
- package/src/widgets/form/MonthField.js +28 -25
- package/src/widgets/form/MonthPicker.d.ts +6 -0
- package/src/widgets/form/MonthPicker.js +5 -4
- package/src/widgets/overlay/Overlay.js +7 -7
- package/src/widgets/overlay/Window.js +1 -1
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);
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
interface Aggregator {
|
|
2
|
-
process(value: number, weight?: number);
|
|
3
|
-
getResult(): number;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export class AggregateFunction {
|
|
7
|
-
static sum(): Aggregator;
|
|
8
|
-
|
|
9
|
-
static avg(): Aggregator;
|
|
10
|
-
|
|
11
|
-
static count(): Aggregator;
|
|
12
|
-
|
|
13
|
-
static distinct(): Aggregator;
|
|
14
|
-
|
|
15
|
-
static min(): Aggregator;
|
|
16
|
-
|
|
17
|
-
static max(): Aggregator;
|
|
18
|
-
|
|
19
|
-
static last(): Aggregator;
|
|
20
|
-
}
|
|
1
|
+
interface Aggregator {
|
|
2
|
+
process(value: number, weight?: number);
|
|
3
|
+
getResult(): number;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export class AggregateFunction {
|
|
7
|
+
static sum(): Aggregator;
|
|
8
|
+
|
|
9
|
+
static avg(): Aggregator;
|
|
10
|
+
|
|
11
|
+
static count(): Aggregator;
|
|
12
|
+
|
|
13
|
+
static distinct(): Aggregator;
|
|
14
|
+
|
|
15
|
+
static min(): Aggregator;
|
|
16
|
+
|
|
17
|
+
static max(): Aggregator;
|
|
18
|
+
|
|
19
|
+
static last(): Aggregator;
|
|
20
|
+
}
|
|
@@ -1,145 +1,145 @@
|
|
|
1
|
-
export class AggregateFunction {
|
|
2
|
-
static sum() {
|
|
3
|
-
return new Sum();
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
static avg() {
|
|
7
|
-
return new Avg();
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
static count() {
|
|
11
|
-
return new Count();
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
static distinct() {
|
|
15
|
-
return new Distinct();
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
static min() {
|
|
19
|
-
return new Min();
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
static max() {
|
|
23
|
-
return new Max();
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
static last() {
|
|
27
|
-
return new LastValue();
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
class Sum {
|
|
32
|
-
process(value) {
|
|
33
|
-
this.empty = false;
|
|
34
|
-
if (!isNaN(value)) this.result += value;
|
|
35
|
-
else this.invalid = true;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
getResult() {
|
|
39
|
-
if (this.invalid) return null;
|
|
40
|
-
return this.result;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
Sum.prototype.result = 0;
|
|
45
|
-
Sum.prototype.empty = true;
|
|
46
|
-
|
|
47
|
-
class Avg {
|
|
48
|
-
process(value, count = 1) {
|
|
49
|
-
this.empty = false;
|
|
50
|
-
if (!isNaN(value) && !isNaN(count)) {
|
|
51
|
-
this.result += value * count;
|
|
52
|
-
this.count += count;
|
|
53
|
-
} else this.invalid = true;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
getResult() {
|
|
57
|
-
if (this.empty || this.invalid || this.count == 0) return null;
|
|
58
|
-
return this.result / this.count;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
Avg.prototype.result = 0;
|
|
63
|
-
Avg.prototype.count = 0;
|
|
64
|
-
Avg.prototype.empty = true;
|
|
65
|
-
|
|
66
|
-
class Count {
|
|
67
|
-
process(value) {
|
|
68
|
-
if (value != null) this.result++;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
getResult() {
|
|
72
|
-
return this.result;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
Count.prototype.result = 0;
|
|
77
|
-
|
|
78
|
-
class Distinct {
|
|
79
|
-
constructor() {
|
|
80
|
-
this.values = {};
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
process(value) {
|
|
84
|
-
if (value == null || this.values[value]) return;
|
|
85
|
-
this.values[value] = true;
|
|
86
|
-
this.empty = false;
|
|
87
|
-
this.result++;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
getResult() {
|
|
91
|
-
if (this.empty || this.invalid) return null;
|
|
92
|
-
return this.result;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
Distinct.prototype.result = 0;
|
|
97
|
-
Distinct.prototype.empty = true;
|
|
98
|
-
|
|
99
|
-
class Max {
|
|
100
|
-
process(value) {
|
|
101
|
-
if (!isNaN(value)) {
|
|
102
|
-
if (this.empty) this.result = value;
|
|
103
|
-
else if (value > this.result) this.result = value;
|
|
104
|
-
this.empty = false;
|
|
105
|
-
} else if (value != null) this.invalid = true;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
getResult() {
|
|
109
|
-
if (this.empty || this.invalid) return null;
|
|
110
|
-
return this.result;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
Max.prototype.result = 0;
|
|
115
|
-
Max.prototype.empty = true;
|
|
116
|
-
|
|
117
|
-
class Min {
|
|
118
|
-
process(value) {
|
|
119
|
-
if (!isNaN(value)) {
|
|
120
|
-
if (this.empty) this.result = value;
|
|
121
|
-
else if (value < this.result) this.result = value;
|
|
122
|
-
this.empty = false;
|
|
123
|
-
} else if (value != null) this.invalid = true;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
getResult() {
|
|
127
|
-
if (this.empty || this.invalid) return null;
|
|
128
|
-
return this.result;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
Min.prototype.result = 0;
|
|
133
|
-
Min.prototype.empty = true;
|
|
134
|
-
|
|
135
|
-
class LastValue {
|
|
136
|
-
process(value) {
|
|
137
|
-
this.result = value;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
getResult() {
|
|
141
|
-
return this.result;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
LastValue.prototype.result = null;
|
|
1
|
+
export class AggregateFunction {
|
|
2
|
+
static sum() {
|
|
3
|
+
return new Sum();
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
static avg() {
|
|
7
|
+
return new Avg();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
static count() {
|
|
11
|
+
return new Count();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
static distinct() {
|
|
15
|
+
return new Distinct();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
static min() {
|
|
19
|
+
return new Min();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
static max() {
|
|
23
|
+
return new Max();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
static last() {
|
|
27
|
+
return new LastValue();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
class Sum {
|
|
32
|
+
process(value) {
|
|
33
|
+
this.empty = false;
|
|
34
|
+
if (!isNaN(value)) this.result += value;
|
|
35
|
+
else this.invalid = true;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
getResult() {
|
|
39
|
+
if (this.invalid) return null;
|
|
40
|
+
return this.result;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
Sum.prototype.result = 0;
|
|
45
|
+
Sum.prototype.empty = true;
|
|
46
|
+
|
|
47
|
+
class Avg {
|
|
48
|
+
process(value, count = 1) {
|
|
49
|
+
this.empty = false;
|
|
50
|
+
if (!isNaN(value) && !isNaN(count)) {
|
|
51
|
+
this.result += value * count;
|
|
52
|
+
this.count += count;
|
|
53
|
+
} else this.invalid = true;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
getResult() {
|
|
57
|
+
if (this.empty || this.invalid || this.count == 0) return null;
|
|
58
|
+
return this.result / this.count;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
Avg.prototype.result = 0;
|
|
63
|
+
Avg.prototype.count = 0;
|
|
64
|
+
Avg.prototype.empty = true;
|
|
65
|
+
|
|
66
|
+
class Count {
|
|
67
|
+
process(value) {
|
|
68
|
+
if (value != null) this.result++;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
getResult() {
|
|
72
|
+
return this.result;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
Count.prototype.result = 0;
|
|
77
|
+
|
|
78
|
+
class Distinct {
|
|
79
|
+
constructor() {
|
|
80
|
+
this.values = {};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
process(value) {
|
|
84
|
+
if (value == null || this.values[value]) return;
|
|
85
|
+
this.values[value] = true;
|
|
86
|
+
this.empty = false;
|
|
87
|
+
this.result++;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
getResult() {
|
|
91
|
+
if (this.empty || this.invalid) return null;
|
|
92
|
+
return this.result;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
Distinct.prototype.result = 0;
|
|
97
|
+
Distinct.prototype.empty = true;
|
|
98
|
+
|
|
99
|
+
class Max {
|
|
100
|
+
process(value) {
|
|
101
|
+
if (!isNaN(value)) {
|
|
102
|
+
if (this.empty) this.result = value;
|
|
103
|
+
else if (value > this.result) this.result = value;
|
|
104
|
+
this.empty = false;
|
|
105
|
+
} else if (value != null) this.invalid = true;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
getResult() {
|
|
109
|
+
if (this.empty || this.invalid) return null;
|
|
110
|
+
return this.result;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
Max.prototype.result = 0;
|
|
115
|
+
Max.prototype.empty = true;
|
|
116
|
+
|
|
117
|
+
class Min {
|
|
118
|
+
process(value) {
|
|
119
|
+
if (!isNaN(value)) {
|
|
120
|
+
if (this.empty) this.result = value;
|
|
121
|
+
else if (value < this.result) this.result = value;
|
|
122
|
+
this.empty = false;
|
|
123
|
+
} else if (value != null) this.invalid = true;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
getResult() {
|
|
127
|
+
if (this.empty || this.invalid) return null;
|
|
128
|
+
return this.result;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
Min.prototype.result = 0;
|
|
133
|
+
Min.prototype.empty = true;
|
|
134
|
+
|
|
135
|
+
class LastValue {
|
|
136
|
+
process(value) {
|
|
137
|
+
this.result = value;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
getResult() {
|
|
141
|
+
return this.result;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
LastValue.prototype.result = null;
|
|
@@ -82,7 +82,12 @@ interface MonthFieldProps extends FieldProps {
|
|
|
82
82
|
* Set to `true` to display the clear button even if `required` is set. Default is `false`.
|
|
83
83
|
*/
|
|
84
84
|
alwaysShowClear?: boolean,
|
|
85
|
-
|
|
85
|
+
|
|
86
|
+
/** The function that will be used to convert Date objects before writing data to the store.
|
|
87
|
+
* Default implementation is Date.toISOString.
|
|
88
|
+
* See also Culture.setDefaultDateEncoding.
|
|
89
|
+
*/
|
|
90
|
+
encoding?: (date: Date) => any;
|
|
86
91
|
}
|
|
87
92
|
|
|
88
93
|
export class MonthField extends Cx.Widget<MonthFieldProps> {}
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import { Widget, VDOM, getContent } from "../../ui/Widget";
|
|
2
|
-
import { Cx } from "../../ui/Cx";
|
|
3
|
-
import { Field, getFieldTooltip } from "./Field";
|
|
4
|
-
import { MonthPicker } from "./MonthPicker";
|
|
5
1
|
import { DateTimeCulture } from "intl-io";
|
|
6
|
-
import { Format } from "../../util/Format";
|
|
7
|
-
import { Dropdown } from "../overlay/Dropdown";
|
|
8
|
-
import { Console } from "../../util/Console";
|
|
9
2
|
import { StringTemplate } from "../../data/StringTemplate";
|
|
10
|
-
import {
|
|
3
|
+
import { Culture } from "../../ui";
|
|
4
|
+
import { Cx } from "../../ui/Cx";
|
|
5
|
+
import { Localization } from "../../ui/Localization";
|
|
6
|
+
import { VDOM, Widget, getContent } from "../../ui/Widget";
|
|
7
|
+
import { Console } from "../../util/Console";
|
|
8
|
+
import { Format } from "../../util/Format";
|
|
9
|
+
import { KeyCode } from "../../util/KeyCode";
|
|
11
10
|
import { dateDiff } from "../../util/date/dateDiff";
|
|
11
|
+
import { monthStart } from "../../util/date/monthStart";
|
|
12
|
+
import { stopPropagation } from "../../util/eventCallbacks";
|
|
13
|
+
import { isDefined } from "../../util/isDefined";
|
|
14
|
+
import { isTouchDevice } from "../../util/isTouchDevice";
|
|
15
|
+
import { isTouchEvent } from "../../util/isTouchEvent";
|
|
16
|
+
import { Icon } from "../Icon";
|
|
17
|
+
import { autoFocus } from "../autoFocus";
|
|
18
|
+
import ClearIcon from "../icons/clear";
|
|
19
|
+
import DropdownIcon from "../icons/drop-down";
|
|
20
|
+
import { Dropdown } from "../overlay/Dropdown";
|
|
12
21
|
import {
|
|
13
|
-
tooltipParentWillReceiveProps,
|
|
14
|
-
tooltipParentWillUnmount,
|
|
15
|
-
tooltipMouseMove,
|
|
16
22
|
tooltipMouseLeave,
|
|
23
|
+
tooltipMouseMove,
|
|
17
24
|
tooltipParentDidMount,
|
|
25
|
+
tooltipParentWillReceiveProps,
|
|
26
|
+
tooltipParentWillUnmount,
|
|
18
27
|
} from "../overlay/tooltip-ops";
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import CalendarIcon from "../icons/calendar";
|
|
22
|
-
import DropdownIcon from "../icons/drop-down";
|
|
23
|
-
import ClearIcon from "../icons/clear";
|
|
24
|
-
import { KeyCode } from "../../util/KeyCode";
|
|
25
|
-
import { isTouchEvent } from "../../util/isTouchEvent";
|
|
26
|
-
import { isTouchDevice } from "../../util/isTouchDevice";
|
|
27
|
-
import { Localization } from "../../ui/Localization";
|
|
28
|
-
import { isDefined } from "../../util/isDefined";
|
|
29
|
-
import { autoFocus } from "../autoFocus";
|
|
28
|
+
import { Field, getFieldTooltip } from "./Field";
|
|
29
|
+
import { MonthPicker } from "./MonthPicker";
|
|
30
30
|
|
|
31
31
|
export class MonthField extends Field {
|
|
32
32
|
declareData() {
|
|
@@ -179,16 +179,18 @@ export class MonthField extends Field {
|
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
handleSelect(instance, date1, date2) {
|
|
182
|
+
let { widget } = instance;
|
|
183
|
+
let encode = widget.encoding || Culture.getDefaultDateEncoding();
|
|
182
184
|
instance.setState({
|
|
183
185
|
inputError: false,
|
|
184
186
|
});
|
|
185
187
|
if (this.range) {
|
|
186
|
-
let d1 = date1 ? date1
|
|
187
|
-
let d2 = date2 ? date2
|
|
188
|
+
let d1 = date1 ? encode(date1) : this.emptyValue;
|
|
189
|
+
let d2 = date2 ? encode(date2) : this.emptyValue;
|
|
188
190
|
instance.set("from", d1);
|
|
189
191
|
instance.set("to", d2);
|
|
190
192
|
} else {
|
|
191
|
-
let value = date1 ? date1
|
|
193
|
+
let value = date1 ? encode(date1) : this.emptyValue;
|
|
192
194
|
instance.set("value", value);
|
|
193
195
|
}
|
|
194
196
|
}
|
|
@@ -238,6 +240,7 @@ class MonthInput extends VDOM.Component {
|
|
|
238
240
|
items: {
|
|
239
241
|
type: MonthPicker,
|
|
240
242
|
...this.props.monthPicker,
|
|
243
|
+
encoding: widget.encoding,
|
|
241
244
|
autoFocus: true,
|
|
242
245
|
onFocusOut: (e) => {
|
|
243
246
|
this.closeDropdown(e);
|
|
@@ -63,6 +63,12 @@ interface MonthPickerProps extends FieldProps {
|
|
|
63
63
|
/** Minimum exclusive value error text. */
|
|
64
64
|
minExclusiveErrorText?: string,
|
|
65
65
|
|
|
66
|
+
/** The function that will be used to convert Date objects before writing data to the store.
|
|
67
|
+
* Default implementation is Date.toISOString.
|
|
68
|
+
* See also Culture.setDefaultDateEncoding.
|
|
69
|
+
*/
|
|
70
|
+
encoding?: (date: Date) => any;
|
|
71
|
+
|
|
66
72
|
}
|
|
67
73
|
|
|
68
74
|
export class MonthPicker extends Cx.Widget<MonthPickerProps> {}
|
|
@@ -124,7 +124,8 @@ export class MonthPicker extends Field {
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
handleSelect(e, instance, date1, date2) {
|
|
127
|
-
let { data } = instance;
|
|
127
|
+
let { data, widget } = instance;
|
|
128
|
+
let encode = widget.encoding || Culture.getDefaultDateEncoding();
|
|
128
129
|
|
|
129
130
|
if (data.disabled) return;
|
|
130
131
|
|
|
@@ -133,9 +134,9 @@ export class MonthPicker extends Field {
|
|
|
133
134
|
if (this.onBeforeSelect && instance.invoke("onBeforeSelect", e, instance, date1, date2) === false) return;
|
|
134
135
|
|
|
135
136
|
if (this.range) {
|
|
136
|
-
instance.set("from", date1
|
|
137
|
-
instance.set("to", date2
|
|
138
|
-
} else instance.set("value", date1
|
|
137
|
+
instance.set("from", encode(date1));
|
|
138
|
+
instance.set("to", encode(date2));
|
|
139
|
+
} else instance.set("value", encode(date1));
|
|
139
140
|
|
|
140
141
|
if (this.onSelect) instance.invoke("onSelect", instance, date1, date2);
|
|
141
142
|
}
|
|
@@ -348,13 +348,11 @@ export class OverlayComponent extends VDOM.Component {
|
|
|
348
348
|
})}
|
|
349
349
|
style={parseStyle(data.shadowStyle)}
|
|
350
350
|
>
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
/>
|
|
357
|
-
)}
|
|
351
|
+
<div
|
|
352
|
+
key="backdrop"
|
|
353
|
+
className={CSS.element("overlay", "modal-backdrop")}
|
|
354
|
+
onClick={this.onBackdropClick.bind(this)}
|
|
355
|
+
/>
|
|
358
356
|
{content}
|
|
359
357
|
</div>
|
|
360
358
|
);
|
|
@@ -459,6 +457,8 @@ export class OverlayComponent extends VDOM.Component {
|
|
|
459
457
|
|
|
460
458
|
if (widget.backdrop) {
|
|
461
459
|
if (instance.dismiss) instance.dismiss();
|
|
460
|
+
} else if (widget.modal) {
|
|
461
|
+
FocusManager.focus(this.el);
|
|
462
462
|
}
|
|
463
463
|
}
|
|
464
464
|
|
|
@@ -168,7 +168,7 @@ class WindowComponent extends OverlayComponent {
|
|
|
168
168
|
super.onFocusIn();
|
|
169
169
|
if (!this.state.active) {
|
|
170
170
|
if (this.containerEl.contains(document.activeElement)) this.setZIndex(ZIndexManager.next());
|
|
171
|
-
this.setState({ active: true
|
|
171
|
+
this.setState({ active: true });
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
174
|
|