cx 24.4.8 → 24.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/charts.css +5 -0
- package/dist/charts.js +168 -0
- package/dist/manifest.js +844 -840
- package/package.json +1 -1
- package/src/charts/Swimlane.d.ts +24 -0
- package/src/charts/Swimlane.js +140 -0
- package/src/charts/Swimlane.scss +14 -0
- package/src/charts/index.d.ts +1 -0
- package/src/charts/index.js +1 -0
- package/src/charts/index.scss +1 -0
- package/src/data/Binding.d.ts +2 -0
- package/src/data/createAccessorModelProxy.d.ts +1 -1
package/package.json
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as Cx from "../core";
|
|
2
|
+
import { BoundedObjectProps } from "../svg";
|
|
3
|
+
|
|
4
|
+
interface SwimlaneProps extends BoundedObjectProps {
|
|
5
|
+
/** The `x` value binding or expression. */
|
|
6
|
+
x?: Cx.Prop<string | number>;
|
|
7
|
+
|
|
8
|
+
/** The `y` value binding or expression. */
|
|
9
|
+
y?: Cx.Prop<string | number>;
|
|
10
|
+
|
|
11
|
+
/** Represents a swimlane size. */
|
|
12
|
+
size?: Cx.NumberProp;
|
|
13
|
+
|
|
14
|
+
/** Switch to vertical swimlanes. */
|
|
15
|
+
vertical?: boolean;
|
|
16
|
+
|
|
17
|
+
/**The laneOffset property adjusts the positioning of lane elements, enhancing their alignment and readability. */
|
|
18
|
+
laneOffset?: Cx.NumberProp;
|
|
19
|
+
|
|
20
|
+
/** Style object applied to the swimlanes. */
|
|
21
|
+
laneStyle?: StyleProp;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export class Swimlane extends Cx.Widget<SwimlaneProps> {}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { BoundedObject } from "../svg/BoundedObject";
|
|
2
|
+
import { parseStyle } from "../util/parseStyle";
|
|
3
|
+
import { VDOM } from "../ui/Widget";
|
|
4
|
+
import { Rect } from "../svg/util/Rect";
|
|
5
|
+
|
|
6
|
+
export class Swimlane extends BoundedObject {
|
|
7
|
+
init() {
|
|
8
|
+
this.laneStyle = parseStyle(this.laneStyle);
|
|
9
|
+
super.init();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declareData(...args) {
|
|
13
|
+
super.declareData(...args, {
|
|
14
|
+
size: undefined,
|
|
15
|
+
laneOffset: undefined,
|
|
16
|
+
laneStyle: { structured: true },
|
|
17
|
+
vertical: undefined,
|
|
18
|
+
x: undefined,
|
|
19
|
+
y: undefined,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
explore(context, instance) {
|
|
24
|
+
let { data } = instance;
|
|
25
|
+
super.explore(context, instance);
|
|
26
|
+
instance.xAxis = context.axes[this.xAxis];
|
|
27
|
+
instance.yAxis = context.axes[this.yAxis];
|
|
28
|
+
|
|
29
|
+
if (data.vertical) {
|
|
30
|
+
instance.xAxis.acknowledge(data.x, data.size, data.laneOffset);
|
|
31
|
+
} else {
|
|
32
|
+
instance.yAxis.acknowledge(data.y, data.size, data.laneOffset);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
prepare(context, instance) {
|
|
37
|
+
super.prepare(context, instance);
|
|
38
|
+
instance.bounds = this.calculateRect(instance);
|
|
39
|
+
instance.cache("bounds", instance.bounds);
|
|
40
|
+
if (!instance.bounds.isEqual(instance.cached.bounds)) instance.markShouldUpdate(context);
|
|
41
|
+
|
|
42
|
+
context.push("parentRect", instance.bounds);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
calculateRect(instance) {
|
|
46
|
+
var { data } = instance;
|
|
47
|
+
var { size, laneOffset } = data;
|
|
48
|
+
|
|
49
|
+
if (data.vertical) {
|
|
50
|
+
var x1 = instance.xAxis.map(data.x, laneOffset - size / 2);
|
|
51
|
+
var x2 = instance.xAxis.map(data.x, laneOffset + size / 2);
|
|
52
|
+
var bounds = new Rect({
|
|
53
|
+
l: Math.min(x1, x2),
|
|
54
|
+
r: Math.max(x1, x2),
|
|
55
|
+
t: data.bounds.t,
|
|
56
|
+
b: data.bounds.b,
|
|
57
|
+
});
|
|
58
|
+
} else {
|
|
59
|
+
var y1 = instance.yAxis.map(data.y, laneOffset - size / 2);
|
|
60
|
+
var y2 = instance.yAxis.map(data.y, laneOffset + size / 2);
|
|
61
|
+
var bounds = new Rect({
|
|
62
|
+
l: data.bounds.l,
|
|
63
|
+
r: data.bounds.r,
|
|
64
|
+
t: Math.min(y1, y2),
|
|
65
|
+
b: Math.max(y1, y2),
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return bounds;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
render(context, instance, key) {
|
|
73
|
+
let { data, xAxis, yAxis, bounds } = instance;
|
|
74
|
+
let { CSS, baseClass } = this;
|
|
75
|
+
|
|
76
|
+
let axis = this.vertical ? xAxis : yAxis;
|
|
77
|
+
if (!axis) return null;
|
|
78
|
+
|
|
79
|
+
let min, max, valueFunction;
|
|
80
|
+
if (axis.scale) {
|
|
81
|
+
min = axis.scale.min;
|
|
82
|
+
max = axis.scale.max;
|
|
83
|
+
let clamp = (value) => [Math.max(min, Math.min(max, value)), 0];
|
|
84
|
+
valueFunction = (value, offset) => clamp(value + offset);
|
|
85
|
+
} else if (axis.valueList) {
|
|
86
|
+
min = 0;
|
|
87
|
+
max = axis.valueList.length;
|
|
88
|
+
valueFunction = (value, offset) => [axis.valueList[value], offset];
|
|
89
|
+
}
|
|
90
|
+
if (!(min < max)) return null;
|
|
91
|
+
|
|
92
|
+
let rectClass = CSS.element(baseClass, "lane");
|
|
93
|
+
|
|
94
|
+
if (this.vertical) {
|
|
95
|
+
let c1 = axis.map(...valueFunction(data.x, -data.size / 2 + data.laneOffset));
|
|
96
|
+
let c2 = axis.map(...valueFunction(data.x, +data.size / 2 + data.laneOffset));
|
|
97
|
+
return (
|
|
98
|
+
<g key={key} className={data.classNames}>
|
|
99
|
+
<rect
|
|
100
|
+
key={key}
|
|
101
|
+
x={bounds.l}
|
|
102
|
+
y={bounds.t}
|
|
103
|
+
height={bounds.b - bounds.t}
|
|
104
|
+
width={Math.abs(c1 - c2)}
|
|
105
|
+
className={rectClass}
|
|
106
|
+
style={data.laneStyle}
|
|
107
|
+
/>
|
|
108
|
+
{this.renderChildren(context, instance)};
|
|
109
|
+
</g>
|
|
110
|
+
);
|
|
111
|
+
} else {
|
|
112
|
+
let c1 = axis.map(...valueFunction(data.y, -data.size / 2 + data.laneOffset));
|
|
113
|
+
let c2 = axis.map(...valueFunction(data.y, +data.size / 2 + data.laneOffset));
|
|
114
|
+
return (
|
|
115
|
+
<g key={key} className={data.classNames}>
|
|
116
|
+
<rect
|
|
117
|
+
key={key}
|
|
118
|
+
x={bounds.l}
|
|
119
|
+
y={bounds.t}
|
|
120
|
+
width={bounds.r - bounds.l}
|
|
121
|
+
height={Math.abs(c1 - c2)}
|
|
122
|
+
className={rectClass}
|
|
123
|
+
style={data.laneStyle}
|
|
124
|
+
/>
|
|
125
|
+
{this.renderChildren(context, instance)};
|
|
126
|
+
</g>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
Swimlane.prototype.xAxis = "x";
|
|
133
|
+
Swimlane.prototype.yAxis = "y";
|
|
134
|
+
Swimlane.prototype.anchors = "0 1 1 0";
|
|
135
|
+
Swimlane.prototype.baseClass = "swimlane";
|
|
136
|
+
Swimlane.prototype.size = 0.5;
|
|
137
|
+
Swimlane.prototype.laneOffset = 0;
|
|
138
|
+
Swimlane.prototype.vertical = false;
|
|
139
|
+
|
|
140
|
+
BoundedObject.alias("swimlane", Swimlane);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
@mixin cx-swimlane($name: "swimlane", $besm: $cx-besm, $lane-color: $cx-default-swimlanes-lane-background-color) {
|
|
2
|
+
$block: map-get($besm, block);
|
|
3
|
+
$element: map-get($besm, element);
|
|
4
|
+
$state: map-get($besm, state);
|
|
5
|
+
|
|
6
|
+
.#{$element}#{$name}-lane {
|
|
7
|
+
fill: $lane-color;
|
|
8
|
+
stroke: none;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
@if (cx-should-include("cx/charts/Swimlane")) {
|
|
13
|
+
@include cx-swimlane();
|
|
14
|
+
}
|
package/src/charts/index.d.ts
CHANGED
package/src/charts/index.js
CHANGED
package/src/charts/index.scss
CHANGED
package/src/data/Binding.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ import { AccessorChain } from "../core";
|
|
|
3
3
|
export function isAccessorChain(value: any): boolean;
|
|
4
4
|
export function isAccessorChain<V>(value: any): value is AccessorChain<V>;
|
|
5
5
|
|
|
6
|
-
export function createAccessorModelProxy<M>(): AccessorChain<M>;
|
|
6
|
+
export function createAccessorModelProxy<M>(basePath: string = ""): AccessorChain<M>;
|