cx 24.3.11 → 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.
@@ -0,0 +1,155 @@
1
+ import { BoundedObject } from "../svg/BoundedObject";
2
+ import { Rect } from "../svg/util/Rect";
3
+ import { Widget } from "../ui/Widget";
4
+ import { parseStyle } from "../util/parseStyle";
5
+
6
+ export class RangeMarker extends BoundedObject {
7
+ declareData() {
8
+ super.declareData(...arguments, {
9
+ x: undefined,
10
+ y: undefined,
11
+ shape: undefined,
12
+ vertical: undefined,
13
+ size: undefined,
14
+ laneOffset: undefined,
15
+ lineStyle: { structured: true },
16
+ lineClass: { structured: true },
17
+ capSize: undefined,
18
+ inflate: undefined,
19
+ });
20
+ }
21
+
22
+ init() {
23
+ this.lineStyle = parseStyle(this.lineStyle);
24
+ super.init();
25
+ }
26
+
27
+ prepareData(context, instance) {
28
+ instance.axes = context.axes;
29
+ instance.xAxis = context.axes[this.xAxis];
30
+ instance.yAxis = context.axes[this.yAxis];
31
+ super.prepareData(context, instance);
32
+ }
33
+
34
+ explore(context, instance) {
35
+ let { data, xAxis, yAxis } = instance;
36
+
37
+ if (this.affectsAxes) {
38
+ if (xAxis && data.x != null) xAxis.acknowledge(data.x, 0, 0);
39
+ if (yAxis && data.y != null) yAxis.acknowledge(data.y, 0, 0);
40
+ }
41
+
42
+ super.explore(context, instance);
43
+ }
44
+
45
+ calculateBounds(context, instance) {
46
+ let { data, xAxis, yAxis } = instance;
47
+
48
+ let l, r, t, b;
49
+
50
+ if (data.x == null || data.y == null) {
51
+ return super.calculateBounds(context, instance);
52
+ }
53
+
54
+ if (!this.vertical) {
55
+ l = xAxis.map(data.x, data.laneOffset - data.size / 2) - data.inflate;
56
+ r = xAxis.map(data.x, data.laneOffset + data.size / 2) + data.inflate;
57
+ t = b = yAxis.map(data.y);
58
+ if (data.shape == "max") {
59
+ b += data.capSize;
60
+ } else if (data.shape == "min") {
61
+ t -= data.capSize;
62
+ }
63
+ } else {
64
+ l = r = xAxis.map(data.x);
65
+ t = yAxis.map(data.y, data.laneOffset - data.size / 2) + data.inflate;
66
+ b = yAxis.map(data.y, data.laneOffset + data.size / 2) - data.inflate;
67
+ if (data.shape == "max") {
68
+ l -= data.capSize;
69
+ } else if (data.shape == "min") {
70
+ r += data.capSize;
71
+ }
72
+ }
73
+
74
+ return new Rect({
75
+ l,
76
+ r,
77
+ t,
78
+ b,
79
+ });
80
+ }
81
+
82
+ prepare(context, instance) {
83
+ super.prepare(context, instance);
84
+ }
85
+
86
+ render(context, instance, key) {
87
+ var { data } = instance;
88
+ let { CSS, baseClass } = this;
89
+ let { bounds, shape } = data;
90
+
91
+ let path = "";
92
+ if (this.vertical) {
93
+ switch (shape) {
94
+ default:
95
+ case "line":
96
+ path += `M ${bounds.r} ${bounds.t} `;
97
+ path += `L ${bounds.r} ${bounds.b}`;
98
+ break;
99
+ case "max":
100
+ path += `M ${bounds.l} ${bounds.t} `;
101
+ path += `L ${bounds.r} ${bounds.t}`;
102
+ path += `L ${bounds.r} ${bounds.b}`;
103
+ path += `L ${bounds.l} ${bounds.b}`;
104
+ break;
105
+ case "min":
106
+ path += `M ${bounds.r} ${bounds.t} `;
107
+ path += `L ${bounds.l} ${bounds.t}`;
108
+ path += `L ${bounds.l} ${bounds.b}`;
109
+ path += `L ${bounds.r} ${bounds.b}`;
110
+ break;
111
+ }
112
+ } else {
113
+ switch (shape) {
114
+ default:
115
+ case "line":
116
+ path += `M ${bounds.r} ${bounds.t} `;
117
+ path += `L ${bounds.l} ${bounds.t}`;
118
+ break;
119
+ case "max":
120
+ path += `M ${bounds.l} ${bounds.b} `;
121
+ path += `L ${bounds.l} ${bounds.t}`;
122
+ path += `L ${bounds.r} ${bounds.t}`;
123
+ path += `L ${bounds.r} ${bounds.b}`;
124
+ break;
125
+ case "min":
126
+ path += `M ${bounds.l} ${bounds.t} `;
127
+ path += `L ${bounds.l} ${bounds.b}`;
128
+ path += `L ${bounds.r} ${bounds.b}`;
129
+ path += `L ${bounds.r} ${bounds.t}`;
130
+ break;
131
+ }
132
+ }
133
+
134
+ return (
135
+ <g key={key} class={data.classNames} style={data.style}>
136
+ <path d={path} class={CSS.expand(CSS.element(baseClass, "path"), data.lineClass)} style={data.lineStyle} />
137
+ {this.renderChildren(context, instance)}
138
+ </g>
139
+ );
140
+ }
141
+ }
142
+
143
+ RangeMarker.prototype.baseClass = "rangemarker";
144
+ RangeMarker.prototype.xAxis = "x";
145
+ RangeMarker.prototype.yAxis = "y";
146
+
147
+ RangeMarker.prototype.shape = "line";
148
+ RangeMarker.prototype.vertical = false;
149
+ RangeMarker.prototype.size = 1;
150
+ RangeMarker.prototype.laneOffset = 0;
151
+ RangeMarker.prototype.capSize = 5;
152
+ RangeMarker.prototype.inflate = 0;
153
+ RangeMarker.prototype.affectsAxes = true;
154
+
155
+ Widget.alias("range-marker", RangeMarker);
@@ -0,0 +1,15 @@
1
+ @mixin cx-rangemarker($name: "rangemarker", $besm: $cx-besm, $range-marker-color: $cx-default-range-marker-color) {
2
+ $block: map-get($besm, block);
3
+ $element: map-get($besm, element);
4
+ $state: map-get($besm, state);
5
+
6
+ .#{$element}#{$name}-path {
7
+ stroke: $range-marker-color;
8
+ fill: none;
9
+ stroke-width: 1px;
10
+ }
11
+ }
12
+
13
+ @if (cx-should-include("cx/charts/RangeMarker")) {
14
+ @include cx-rangemarker();
15
+ }
@@ -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;