cx 24.3.10 → 24.4.0

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.
@@ -1,66 +1,64 @@
1
- import * as Cx from '../core';
2
- import {PropertySelection, KeySelection} from '../ui/selection';
1
+ import * as Cx from "../core";
2
+ import { PropertySelection, KeySelection } from "../ui/selection";
3
3
 
4
4
  interface ScatterGraphProps extends Cx.StyledContainerProps {
5
-
6
- /**
5
+ /**
7
6
  * Data for the graph. Each entry should be an object with at least two properties
8
- * whose names should match the `xField` and `yField` values.
7
+ * whose names should match the `xField` and `yField` values.
9
8
  */
10
- data?: Cx.RecordsProp,
9
+ data?: Cx.RecordsProp;
11
10
 
12
11
  /** Size (width) of the column in axis units. */
13
- size?: Cx.NumberProp,
12
+ size?: Cx.NumberProp;
14
13
 
15
- shape?: Cx.StringProp,
14
+ shape?: Cx.StringProp;
16
15
 
17
16
  /** Index of a color from the standard palette of colors. 0-15. */
18
- colorIndex?: Cx.NumberProp,
17
+ colorIndex?: Cx.NumberProp;
19
18
 
20
19
  /** Used to automatically assign a color based on the `name` and the contextual `ColorMap` widget. */
21
- colorMap?: Cx.StringProp,
20
+ colorMap?: Cx.StringProp;
22
21
 
23
22
  /** Name used to resolve the color. If not provided, `name` is used instead. */
24
- colorName?: Cx.StringProp,
23
+ colorName?: Cx.StringProp;
25
24
 
26
25
  /** Name of the item as it will appear in the legend. */
27
- name?: Cx.StringProp,
26
+ name?: Cx.StringProp;
28
27
 
29
28
  /** Used to indicate if an item is active or not. Inactive items are shown only in the legend. */
30
- active?: Cx.BooleanProp,
31
-
29
+ active?: Cx.BooleanProp;
30
+
32
31
  /** Base CSS class to be applied to the element. Defaults to `scattergraph`. */
33
- baseClass?: string,
32
+ baseClass?: string;
34
33
 
35
- /**
36
- * Name of the horizontal axis. The value should match one of the horizontal axes set
37
- * in the `axes` configuration of the parent `Chart` component. Default value is `x`.
34
+ /**
35
+ * Name of the horizontal axis. The value should match one of the horizontal axes set
36
+ * in the `axes` configuration of the parent `Chart` component. Default value is `x`.
38
37
  */
39
- xAxis?: string,
38
+ xAxis?: string;
40
39
 
41
- /**
42
- * Name of the vertical axis. The value should match one of the vertical axes set
43
- * in the `axes` configuration if the parent `Chart` component. Default value is `y`.
40
+ /**
41
+ * Name of the vertical axis. The value should match one of the vertical axes set
42
+ * in the `axes` configuration if the parent `Chart` component. Default value is `y`.
44
43
  */
45
- yAxis?: string,
44
+ yAxis?: string;
46
45
 
47
46
  /** Name of the property which holds the x value. Default value is `x`. */
48
- xField?: string,
47
+ xField?: string;
49
48
 
50
49
  /** Name of the property which holds the y value. Default value is `y`. */
51
- yField?: string,
50
+ yField?: string;
52
51
 
53
52
  /** Name of the property which holds the size value. Do not set if `size` is used. */
54
- sizeField?: string,
53
+ sizeField?: string | false;
55
54
 
56
55
  /** Name of the legend to be used. Default is legend. */
57
- legend?: string,
58
-
59
- legendAction?: string,
56
+ legend?: string;
60
57
 
61
- /** Selection configuration. */
62
- selection?: { type: typeof PropertySelection | typeof KeySelection, [prop: string]: any }
58
+ legendAction?: string;
63
59
 
60
+ /** Selection configuration. */
61
+ selection?: { type: typeof PropertySelection | typeof KeySelection; [prop: string]: any };
64
62
  }
65
63
 
66
- export class ScatterGraph extends Cx.Widget<ScatterGraphProps> {}
64
+ export class ScatterGraph extends Cx.Widget<ScatterGraphProps> {}
@@ -20,6 +20,7 @@ export * from "./ScatterGraph";
20
20
  export * from "./BubbleGraph";
21
21
  export * from "./shapes";
22
22
  export * from "./MouseTracker";
23
+ export * from "./RangeMarker";
23
24
 
24
25
  export * from "./axis/index";
25
26
  export * from "./helpers/index";
@@ -17,6 +17,7 @@ export * from "./MarkerLine";
17
17
  export * from "./Range";
18
18
  export * from "./Gridlines";
19
19
  export * from "./Swimlanes";
20
+ export * from "./RangeMarker";
20
21
 
21
22
  export * from "./LineGraph";
22
23
  export * from "./ColumnGraph";
@@ -15,6 +15,7 @@
15
15
  @import "Marker";
16
16
  @import "MarkerLine";
17
17
  @import "Range";
18
+ @import "RangeMarker";
18
19
 
19
20
  //define last for higher priority
20
21
  @import "palette";
@@ -1,20 +1,21 @@
1
- @import "axis/variables";
2
-
3
- $cx-default-swimlanes-lane-background-color: #f1f1f1;
4
-
5
- $cx-dependencies: map-merge(
6
- $cx-dependencies,
7
- (
8
- "cx/charts/Bar": "cx/charts/palette",
9
- "cx/charts/BarGraph": "cx/charts/palette",
10
- "cx/charts/Column": "cx/charts/palette",
11
- "cx/charts/ColumnGraph": "cx/charts/palette",
12
- "cx/charts/LineGraph": "cx/charts/palette",
13
- "cx/charts/ColorMap": "cx/charts/palette",
14
- "cx/charts/ScatterGraph": "cx/charts/palette",
15
- "cx/charts/BubbleGraph": "cx/charts/palette",
16
- "cx/charts/MarkerLine": "cx/charts/palette",
17
- "cx/charts/Marker": "cx/charts/palette",
18
- "cx/charts/PieChart": "cx/charts/palette",
19
- )
20
- );
1
+ @import "axis/variables";
2
+
3
+ $cx-default-swimlanes-lane-background-color: #f1f1f1;
4
+ $cx-default-range-marker-color: #696969;
5
+
6
+ $cx-dependencies: map-merge(
7
+ $cx-dependencies,
8
+ (
9
+ "cx/charts/Bar": "cx/charts/palette",
10
+ "cx/charts/BarGraph": "cx/charts/palette",
11
+ "cx/charts/Column": "cx/charts/palette",
12
+ "cx/charts/ColumnGraph": "cx/charts/palette",
13
+ "cx/charts/LineGraph": "cx/charts/palette",
14
+ "cx/charts/ColorMap": "cx/charts/palette",
15
+ "cx/charts/ScatterGraph": "cx/charts/palette",
16
+ "cx/charts/BubbleGraph": "cx/charts/palette",
17
+ "cx/charts/MarkerLine": "cx/charts/palette",
18
+ "cx/charts/Marker": "cx/charts/palette",
19
+ "cx/charts/PieChart": "cx/charts/palette",
20
+ )
21
+ );
@@ -1,17 +1,17 @@
1
- import { Selector } from "../core";
2
-
3
- export function expression(str: string): Selector<any>;
4
-
5
- export class Expression {
6
- static get(str: string): Selector<any>;
7
-
8
- static compile(str: string): Selector<any>;
9
-
10
- static registerHelper(name: string, helper);
11
-
12
- static expandFatArrows: boolean;
13
- }
14
-
15
- export function invalidateExpressionCache(): void;
16
-
17
- export function setGetExpressionCacheCallback(callback: () => {}): void;
1
+ import { Selector } from "../core";
2
+
3
+ export function expression(str: string): Selector<any>;
4
+
5
+ export class Expression {
6
+ static get(str: string): Selector<any>;
7
+
8
+ static compile(str: string): Selector<any>;
9
+
10
+ static registerHelper(name: string, helper);
11
+
12
+ static expandFatArrows: boolean;
13
+ }
14
+
15
+ export function invalidateExpressionCache(): void;
16
+
17
+ export function setGetExpressionCacheCallback(callback: () => {}): void;
@@ -1,220 +1,220 @@
1
- import { computable } from "./computable";
2
- import { Format } from "../util/Format";
3
- import { Binding } from "./Binding";
4
-
5
- import { quoteStr } from "../util/quote";
6
- import { isDigit } from "../util/isDigit";
7
- import { isFunction } from "../util/isFunction";
8
-
9
- /*
10
- Helper usage example
11
-
12
- Expression.registerHelper('_', _);
13
- let e = Expression.compile('_.min({data})');
14
- */
15
-
16
- let helpers = {},
17
- helperNames = [],
18
- helperValues = [],
19
- expFatArrows = null;
20
-
21
- function getExpr(expr) {
22
- if (expr.memoize) return expr;
23
-
24
- function memoize() {
25
- let lastValue,
26
- lastRunBindings = {},
27
- lastRunResults = {},
28
- getters = {},
29
- currentData,
30
- len = -1;
31
-
32
- let get = function (bindingWithFormat) {
33
- let getter = getters[bindingWithFormat];
34
- if (!getter) {
35
- let binding = bindingWithFormat,
36
- format;
37
- let colonIndex = bindingWithFormat.indexOf(":");
38
- if (colonIndex != -1) {
39
- format = Format.parse(bindingWithFormat.substring(colonIndex + 1));
40
- binding = bindingWithFormat.substring(0, colonIndex);
41
- } else {
42
- let nullSeparatorIndex = bindingWithFormat.indexOf(":");
43
- if (nullSeparatorIndex != -1) {
44
- format = Format.parse(bindingWithFormat.substring(nullSeparatorIndex));
45
- binding = bindingWithFormat.substring(0, nullSeparatorIndex - 1);
46
- }
47
- }
48
- let b = Binding.get(binding);
49
- getter = (data) => {
50
- let value = b.value(data);
51
- lastRunBindings[len] = b.value;
52
- lastRunResults[len] = value;
53
- len++;
54
- return value;
55
- };
56
-
57
- if (format) {
58
- let valueGetter = getter;
59
- getter = (data) => format(valueGetter(data));
60
- }
61
-
62
- getters[bindingWithFormat] = getter;
63
- }
64
- return getter(currentData);
65
- };
66
-
67
- return function (data) {
68
- let i = 0;
69
- for (; i < len; i++) if (lastRunBindings[i](data) !== lastRunResults[i]) break;
70
- if (i !== len) {
71
- len = 0;
72
- currentData = data;
73
- lastValue = expr(get);
74
- }
75
- return lastValue;
76
- };
77
- }
78
-
79
- let result = memoize();
80
- result.memoize = memoize;
81
- return result;
82
- }
83
-
84
- export function expression(str) {
85
- if (isFunction(str)) return getExpr(str);
86
-
87
- let cache = getExpressionCache();
88
- let r = cache[str];
89
- if (r) return r;
90
-
91
- let quote = false;
92
-
93
- let termStart = -1,
94
- curlyBrackets = 0,
95
- percentExpression;
96
-
97
- let fb = ["return ("];
98
-
99
- let args = {};
100
- let formats = [];
101
- let subExpr = 0;
102
-
103
- for (let i = 0; i < str.length; i++) {
104
- let c = str[i];
105
- switch (c) {
106
- case "{":
107
- if (curlyBrackets > 0) curlyBrackets++;
108
- else {
109
- if (!quote && termStart < 0 && (str[i + 1] != "{" || str[i - 1] == "%")) {
110
- termStart = i + 1;
111
- curlyBrackets = 1;
112
- percentExpression = str[i - 1] == "%";
113
- if (percentExpression) fb.pop(); //%
114
- } else if (str[i - 1] != "{") fb.push(c);
115
- }
116
- break;
117
-
118
- case "}":
119
- if (termStart >= 0) {
120
- if (--curlyBrackets == 0) {
121
- let term = str.substring(termStart, i);
122
- let formatStart = 0;
123
- if (term[0] == "[") formatStart = term.indexOf("]");
124
- let colon = term.indexOf(":", formatStart > 0 ? formatStart : 0);
125
- let binding = colon == -1 ? term : term.substring(0, colon);
126
- let format = colon == -1 ? null : term.substring(colon + 1);
127
- if (colon == -1) {
128
- let nullSepIndex = binding.indexOf("|", formatStart);
129
- if (nullSepIndex != -1) {
130
- format = binding.substring(nullSepIndex);
131
- binding = binding.substring(0, nullSepIndex);
132
- }
133
- }
134
- let argName = binding.replace(/\./g, "_");
135
- if (isDigit(argName[0])) argName = "$" + argName;
136
- if (percentExpression || (binding[0] == "[" && binding[binding.length - 1] == "]")) {
137
- argName = `expr${++subExpr}`;
138
- args[argName] = expression(percentExpression ? binding : binding.substring(1, binding.length - 1));
139
- } else args[argName] = binding;
140
- if (format) {
141
- let formatter = "fmt" + formats.length;
142
- fb.push(formatter, "(", argName, ", ", quoteStr(format), ")");
143
- formats.push(Format.parse(format));
144
- } else fb.push(argName);
145
- termStart = -1;
146
- }
147
- } else fb.push(c);
148
-
149
- break;
150
-
151
- case '"':
152
- case "'":
153
- if (curlyBrackets == 0) {
154
- if (!quote) quote = c;
155
- else if (str[i - 1] != "\\" && quote == c) quote = false;
156
- fb.push(c);
157
- }
158
- break;
159
-
160
- default:
161
- if (termStart < 0) fb.push(c);
162
- break;
163
- }
164
- }
165
-
166
- fb.push(")");
167
-
168
- let body = fb.join("");
169
-
170
- if (expFatArrows) body = expFatArrows(body);
171
-
172
- //console.log(body);
173
- let keys = Object.keys(args);
174
-
175
- try {
176
- let compute = new Function("fmt", ...formats.map((f, i) => "fmt" + i), ...keys, ...helperNames, body).bind(
177
- Format,
178
- Format.value,
179
- ...formats,
180
- ...helperValues,
181
- );
182
- let selector = computable(...keys.map((k) => args[k]), compute);
183
- cache[str] = selector;
184
- return selector;
185
- } catch (err) {
186
- throw new Error(`Failed to parse expression: '${str}'. Error: ${err.message}`);
187
- }
188
- }
189
-
190
- export const Expression = {
191
- get: function (str) {
192
- return expression(str);
193
- },
194
-
195
- compile: function (str) {
196
- return this.get(str).memoize();
197
- },
198
-
199
- registerHelper: function (name, helper) {
200
- helpers[name] = helper;
201
- helperNames = Object.keys(helpers);
202
- helperValues = helperNames.map((n) => helpers[n]);
203
- },
204
- };
205
-
206
- export function plugFatArrowExpansion(impl) {
207
- expFatArrows = impl;
208
- }
209
-
210
- export function invalidateExpressionCache() {
211
- expCache = {};
212
- }
213
-
214
- let expCache = {};
215
-
216
- let getExpressionCache = () => expCache;
217
-
218
- export function setGetExpressionCacheCallback(callback) {
219
- getExpressionCache = callback;
220
- }
1
+ import { computable } from "./computable";
2
+ import { Format } from "../util/Format";
3
+ import { Binding } from "./Binding";
4
+
5
+ import { quoteStr } from "../util/quote";
6
+ import { isDigit } from "../util/isDigit";
7
+ import { isFunction } from "../util/isFunction";
8
+
9
+ /*
10
+ Helper usage example
11
+
12
+ Expression.registerHelper('_', _);
13
+ let e = Expression.compile('_.min({data})');
14
+ */
15
+
16
+ let helpers = {},
17
+ helperNames = [],
18
+ helperValues = [],
19
+ expFatArrows = null;
20
+
21
+ function getExpr(expr) {
22
+ if (expr.memoize) return expr;
23
+
24
+ function memoize() {
25
+ let lastValue,
26
+ lastRunBindings = {},
27
+ lastRunResults = {},
28
+ getters = {},
29
+ currentData,
30
+ len = -1;
31
+
32
+ let get = function (bindingWithFormat) {
33
+ let getter = getters[bindingWithFormat];
34
+ if (!getter) {
35
+ let binding = bindingWithFormat,
36
+ format;
37
+ let colonIndex = bindingWithFormat.indexOf(":");
38
+ if (colonIndex != -1) {
39
+ format = Format.parse(bindingWithFormat.substring(colonIndex + 1));
40
+ binding = bindingWithFormat.substring(0, colonIndex);
41
+ } else {
42
+ let nullSeparatorIndex = bindingWithFormat.indexOf(":");
43
+ if (nullSeparatorIndex != -1) {
44
+ format = Format.parse(bindingWithFormat.substring(nullSeparatorIndex));
45
+ binding = bindingWithFormat.substring(0, nullSeparatorIndex - 1);
46
+ }
47
+ }
48
+ let b = Binding.get(binding);
49
+ getter = (data) => {
50
+ let value = b.value(data);
51
+ lastRunBindings[len] = b.value;
52
+ lastRunResults[len] = value;
53
+ len++;
54
+ return value;
55
+ };
56
+
57
+ if (format) {
58
+ let valueGetter = getter;
59
+ getter = (data) => format(valueGetter(data));
60
+ }
61
+
62
+ getters[bindingWithFormat] = getter;
63
+ }
64
+ return getter(currentData);
65
+ };
66
+
67
+ return function (data) {
68
+ let i = 0;
69
+ for (; i < len; i++) if (lastRunBindings[i](data) !== lastRunResults[i]) break;
70
+ if (i !== len) {
71
+ len = 0;
72
+ currentData = data;
73
+ lastValue = expr(get);
74
+ }
75
+ return lastValue;
76
+ };
77
+ }
78
+
79
+ let result = memoize();
80
+ result.memoize = memoize;
81
+ return result;
82
+ }
83
+
84
+ export function expression(str) {
85
+ if (isFunction(str)) return getExpr(str);
86
+
87
+ let cache = getExpressionCache();
88
+ let r = cache[str];
89
+ if (r) return r;
90
+
91
+ let quote = false;
92
+
93
+ let termStart = -1,
94
+ curlyBrackets = 0,
95
+ percentExpression;
96
+
97
+ let fb = ["return ("];
98
+
99
+ let args = {};
100
+ let formats = [];
101
+ let subExpr = 0;
102
+
103
+ for (let i = 0; i < str.length; i++) {
104
+ let c = str[i];
105
+ switch (c) {
106
+ case "{":
107
+ if (curlyBrackets > 0) curlyBrackets++;
108
+ else {
109
+ if (!quote && termStart < 0 && (str[i + 1] != "{" || str[i - 1] == "%")) {
110
+ termStart = i + 1;
111
+ curlyBrackets = 1;
112
+ percentExpression = str[i - 1] == "%";
113
+ if (percentExpression) fb.pop(); //%
114
+ } else if (str[i - 1] != "{") fb.push(c);
115
+ }
116
+ break;
117
+
118
+ case "}":
119
+ if (termStart >= 0) {
120
+ if (--curlyBrackets == 0) {
121
+ let term = str.substring(termStart, i);
122
+ let formatStart = 0;
123
+ if (term[0] == "[") formatStart = term.indexOf("]");
124
+ let colon = term.indexOf(":", formatStart > 0 ? formatStart : 0);
125
+ let binding = colon == -1 ? term : term.substring(0, colon);
126
+ let format = colon == -1 ? null : term.substring(colon + 1);
127
+ if (colon == -1) {
128
+ let nullSepIndex = binding.indexOf("|", formatStart);
129
+ if (nullSepIndex != -1) {
130
+ format = binding.substring(nullSepIndex);
131
+ binding = binding.substring(0, nullSepIndex);
132
+ }
133
+ }
134
+ let argName = binding.replace(/\./g, "_");
135
+ if (isDigit(argName[0])) argName = "$" + argName;
136
+ if (percentExpression || (binding[0] == "[" && binding[binding.length - 1] == "]")) {
137
+ argName = `expr${++subExpr}`;
138
+ args[argName] = expression(percentExpression ? binding : binding.substring(1, binding.length - 1));
139
+ } else args[argName] = binding;
140
+ if (format) {
141
+ let formatter = "fmt" + formats.length;
142
+ fb.push(formatter, "(", argName, ", ", quoteStr(format), ")");
143
+ formats.push(Format.parse(format));
144
+ } else fb.push(argName);
145
+ termStart = -1;
146
+ }
147
+ } else fb.push(c);
148
+
149
+ break;
150
+
151
+ case '"':
152
+ case "'":
153
+ if (curlyBrackets == 0) {
154
+ if (!quote) quote = c;
155
+ else if (str[i - 1] != "\\" && quote == c) quote = false;
156
+ fb.push(c);
157
+ }
158
+ break;
159
+
160
+ default:
161
+ if (termStart < 0) fb.push(c);
162
+ break;
163
+ }
164
+ }
165
+
166
+ fb.push(")");
167
+
168
+ let body = fb.join("");
169
+
170
+ if (expFatArrows) body = expFatArrows(body);
171
+
172
+ //console.log(body);
173
+ let keys = Object.keys(args);
174
+
175
+ try {
176
+ let compute = new Function("fmt", ...formats.map((f, i) => "fmt" + i), ...keys, ...helperNames, body).bind(
177
+ Format,
178
+ Format.value,
179
+ ...formats,
180
+ ...helperValues,
181
+ );
182
+ let selector = computable(...keys.map((k) => args[k]), compute);
183
+ cache[str] = selector;
184
+ return selector;
185
+ } catch (err) {
186
+ throw new Error(`Failed to parse expression: '${str}'. Error: ${err.message}`);
187
+ }
188
+ }
189
+
190
+ export const Expression = {
191
+ get: function (str) {
192
+ return expression(str);
193
+ },
194
+
195
+ compile: function (str) {
196
+ return this.get(str).memoize();
197
+ },
198
+
199
+ registerHelper: function (name, helper) {
200
+ helpers[name] = helper;
201
+ helperNames = Object.keys(helpers);
202
+ helperValues = helperNames.map((n) => helpers[n]);
203
+ },
204
+ };
205
+
206
+ export function plugFatArrowExpansion(impl) {
207
+ expFatArrows = impl;
208
+ }
209
+
210
+ export function invalidateExpressionCache() {
211
+ expCache = {};
212
+ }
213
+
214
+ let expCache = {};
215
+
216
+ let getExpressionCache = () => expCache;
217
+
218
+ export function setGetExpressionCacheCallback(callback) {
219
+ getExpressionCache = callback;
220
+ }