cx 24.10.4 → 24.10.6

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cx",
3
- "version": "24.10.4",
3
+ "version": "24.10.6",
4
4
  "description": "Advanced JavaScript UI framework for admin and dashboard applications with ready to use grid, form and chart components.",
5
5
  "main": "index.js",
6
6
  "jsnext:main": "src/index.js",
@@ -1,110 +1,113 @@
1
- import { Instance } from "./../../ui/Instance.d";
2
- import * as Cx from "../../core";
3
- import { BoundedObject, BoundedObjectProps } from "../../svg/BoundedObject";
4
-
5
- export interface AxisProps extends BoundedObjectProps {
6
- /** Set to `true` for vertical axes. */
7
- vertical?: boolean;
8
-
9
- /** Used as a secondary axis. Displayed at the top/right. */
10
- secondary?: boolean;
11
-
12
- /** When set to `true`, the values are displayed in descending order. */
13
- inverted?: Cx.BooleanProp;
14
-
15
- /** When set to `true`, rendering of visual elements of the axis, such as ticks and labels, is skipped, but their function is preserved. */
16
- hidden?: boolean;
17
-
18
- /** Size of the axis tick line. Defaults to 3. */
19
- tickSize?: number;
20
-
21
- /** The smallest distance between two ticks on the axis. Defaults to 25. */
22
- minTickDistance?: number;
23
-
24
- /** The smallest distance between two labels on the vertical axis. Defaults to 40. */
25
- minLabelDistanceVertical?: number;
26
-
27
- /** The smallest distance between two labels on the horizontal axis. Defaults to 50. */
28
- minLabelDistanceHorizontal?: number;
29
-
30
- /** Distance between labels and the axis. Defaults to 10. */
31
- labelOffset?: number | string;
32
-
33
- /** Label rotation angle in degrees. */
34
- labelRotation?: Cx.Prop<number | string>;
35
-
36
- /** Label text-anchor value. Allowed values are start, end and middle. Default value is set based on the value of vertical and secondary flags. */
37
- labelAnchor?: "start" | "end" | "middle" | "auto";
38
-
39
- /** Horizontal text offset. */
40
- labelDx?: number | string;
41
-
42
- /** Vertical text offset which can be used for vertical alignment. */
43
- labelDy?: number | string;
44
-
45
- /** Set to `true` to break long labels into multiple lines. Default value is `false`. Text is split at space characters. See also `labelMaxLineLength` and `labelLineCountDyFactor`. */
46
- labelWrap?: boolean;
47
-
48
- /**
49
- * Used for vertical adjustment of multi-line labels. Default value is `auto` which means
50
- * that value is initialized based on axis configuration. Value `0` means that label will grow towards
51
- * the bottom of the screen. Value `-1` will make labels to grow towards the top of the screen.
52
- * `-0.5` will make labels vertically centered.
53
- */
54
- labelLineCountDyFactor?: number | string;
55
-
56
- /**
57
- * Used for vertical adjustment of multi-line labels. Default value is 1 which means
58
- * that labels are stacked without any space between them. Value of 1.4 will add 40% of the label height as a space between labels.
59
- */
60
- labelLineHeight?: number | string;
61
-
62
- /** If `labelWrap` is on, this number is used as a measure to split labels into multiple lines. Default value is `10`. */
63
- labelMaxLineLength?: number;
64
-
65
- /** Set to true to hide the axis labels. */
66
- hideLabels?: boolean;
67
-
68
- /** Set to true to hide the axis line. */
69
- hideLine?: boolean;
70
-
71
- /** Set to true to hide the axis ticks. */
72
- hideTicks?: boolean;
73
-
74
- /** Additional CSS style to be applied to the axis line. */
75
- lineStyle?: Cx.StyleProp;
76
-
77
- /** Additional CSS style to be applied to the axis ticks. */
78
- tickStyle?: Cx.StyleProp;
79
-
80
- /** Additional CSS style to be applied to the axis labels. */
81
- labelStyle?: Cx.StyleProp;
82
-
83
- /** Additional CSS class to be applied to the axis line. */
84
- lineClass?: Cx.ClassProp;
85
-
86
- /** Additional CSS class to be applied to the axis ticks. */
87
- tickClass?: Cx.ClassProp;
88
-
89
- /** Additional CSS class to be applied to the axis labels. */
90
- labelClass?: Cx.ClassProp;
91
-
92
- onMeasured?: (info: any, instance: Instance) => void;
93
-
94
- /** A function used to create a formatter function for axis labels. See Complex Labels example in the CxJS documentation for more info. */
95
- onCreateLabelFormatter?:
96
- | string
97
- | ((
98
- context: any,
99
- instance: Instance,
100
- ) => (
101
- formattedValue: string,
102
- value: any,
103
- { tickIndex, serieIndex }: { tickIndex: number; serieIndex: number },
104
- ) => { text: string; style?: any; className?: string }[]);
105
-
106
- /** Distance between the even labels and the axis. */
107
- alternateLabelOffset?: number | string;
108
- }
109
-
110
- export class Axis extends BoundedObject {}
1
+ import { Instance } from "./../../ui/Instance.d";
2
+ import * as Cx from "../../core";
3
+ import { BoundedObject, BoundedObjectProps } from "../../svg/BoundedObject";
4
+
5
+ export interface AxisProps extends BoundedObjectProps {
6
+ /** Set to `true` for vertical axes. */
7
+ vertical?: boolean;
8
+
9
+ /** Used as a secondary axis. Displayed at the top/right. */
10
+ secondary?: boolean;
11
+
12
+ /** When set to `true`, the values are displayed in descending order. */
13
+ inverted?: Cx.BooleanProp;
14
+
15
+ /** When set to `true`, rendering of visual elements of the axis, such as ticks and labels, is skipped, but their function is preserved. */
16
+ hidden?: boolean;
17
+
18
+ /** Size of the axis tick line. Defaults to 3. */
19
+ tickSize?: number;
20
+
21
+ /** Distance between ticks and the axis. Default is 0. Use negative values for offset to make ticks appear on both sides of the axis. */
22
+ tickOffset?: number;
23
+
24
+ /** The smallest distance between two ticks on the axis. Defaults to 25. */
25
+ minTickDistance?: number;
26
+
27
+ /** The smallest distance between two labels on the vertical axis. Defaults to 40. */
28
+ minLabelDistanceVertical?: number;
29
+
30
+ /** The smallest distance between two labels on the horizontal axis. Defaults to 50. */
31
+ minLabelDistanceHorizontal?: number;
32
+
33
+ /** Distance between labels and the axis. Defaults to 10. */
34
+ labelOffset?: number | string;
35
+
36
+ /** Label rotation angle in degrees. */
37
+ labelRotation?: Cx.Prop<number | string>;
38
+
39
+ /** Label text-anchor value. Allowed values are start, end and middle. Default value is set based on the value of vertical and secondary flags. */
40
+ labelAnchor?: "start" | "end" | "middle" | "auto";
41
+
42
+ /** Horizontal text offset. */
43
+ labelDx?: number | string;
44
+
45
+ /** Vertical text offset which can be used for vertical alignment. */
46
+ labelDy?: number | string;
47
+
48
+ /** Set to `true` to break long labels into multiple lines. Default value is `false`. Text is split at space characters. See also `labelMaxLineLength` and `labelLineCountDyFactor`. */
49
+ labelWrap?: boolean;
50
+
51
+ /**
52
+ * Used for vertical adjustment of multi-line labels. Default value is `auto` which means
53
+ * that value is initialized based on axis configuration. Value `0` means that label will grow towards
54
+ * the bottom of the screen. Value `-1` will make labels to grow towards the top of the screen.
55
+ * `-0.5` will make labels vertically centered.
56
+ */
57
+ labelLineCountDyFactor?: number | string;
58
+
59
+ /**
60
+ * Used for vertical adjustment of multi-line labels. Default value is 1 which means
61
+ * that labels are stacked without any space between them. Value of 1.4 will add 40% of the label height as a space between labels.
62
+ */
63
+ labelLineHeight?: number | string;
64
+
65
+ /** If `labelWrap` is on, this number is used as a measure to split labels into multiple lines. Default value is `10`. */
66
+ labelMaxLineLength?: number;
67
+
68
+ /** Set to true to hide the axis labels. */
69
+ hideLabels?: boolean;
70
+
71
+ /** Set to true to hide the axis line. */
72
+ hideLine?: boolean;
73
+
74
+ /** Set to true to hide the axis ticks. */
75
+ hideTicks?: boolean;
76
+
77
+ /** Additional CSS style to be applied to the axis line. */
78
+ lineStyle?: Cx.StyleProp;
79
+
80
+ /** Additional CSS style to be applied to the axis ticks. */
81
+ tickStyle?: Cx.StyleProp;
82
+
83
+ /** Additional CSS style to be applied to the axis labels. */
84
+ labelStyle?: Cx.StyleProp;
85
+
86
+ /** Additional CSS class to be applied to the axis line. */
87
+ lineClass?: Cx.ClassProp;
88
+
89
+ /** Additional CSS class to be applied to the axis ticks. */
90
+ tickClass?: Cx.ClassProp;
91
+
92
+ /** Additional CSS class to be applied to the axis labels. */
93
+ labelClass?: Cx.ClassProp;
94
+
95
+ onMeasured?: (info: any, instance: Instance) => void;
96
+
97
+ /** A function used to create a formatter function for axis labels. See Complex Labels example in the CxJS documentation for more info. */
98
+ onCreateLabelFormatter?:
99
+ | string
100
+ | ((
101
+ context: any,
102
+ instance: Instance,
103
+ ) => (
104
+ formattedValue: string,
105
+ value: any,
106
+ { tickIndex, serieIndex }: { tickIndex: number; serieIndex: number },
107
+ ) => { text: string; style?: any; className?: string }[]);
108
+
109
+ /** Distance between the even labels and the axis. */
110
+ alternateLabelOffset?: number | string;
111
+ }
112
+
113
+ export class Axis extends BoundedObject {}
@@ -56,13 +56,13 @@ export class Axis extends BoundedObject {
56
56
 
57
57
  reportData(context, instance) {}
58
58
 
59
- renderTicksAndLabels(context, instance, valueFormatter) {
59
+ renderTicksAndLabels(context, instance, valueFormatter, minLabelDistance) {
60
60
  if (this.hidden) return false;
61
61
 
62
62
  var { data, calculator, labelFormatter } = instance;
63
63
  var { bounds } = data;
64
64
  let { CSS, baseClass } = this;
65
- var size = calculator.findTickSize(this.minLabelDistance);
65
+ var size = calculator.findTickSize(minLabelDistance);
66
66
 
67
67
  var labelClass = CSS.expand(CSS.element(baseClass, "label"), data.labelClass);
68
68
  var offsetClass = CSS.element(baseClass, "label-offset");
@@ -71,7 +71,8 @@ export class Axis extends BoundedObject {
71
71
  y1,
72
72
  x2,
73
73
  y2,
74
- tickSize = this.tickSize;
74
+ tickSize = this.tickSize,
75
+ tickOffset = this.tickOffset;
75
76
 
76
77
  if (this.vertical) {
77
78
  x1 = x2 = this.secondary ? bounds.r : bounds.l;
@@ -100,25 +101,25 @@ export class Axis extends BoundedObject {
100
101
  }
101
102
 
102
103
  var t = [];
103
- if (size > 0 && !data.hideLabels) {
104
+ if (!!size && !data.hideLabels) {
104
105
  var ticks = calculator.getTicks([size]);
105
106
  ticks.forEach((serie, si) => {
106
107
  serie.forEach((v, i) => {
107
108
  var s = calculator.map(v);
108
109
 
109
110
  if (this.secondary) {
110
- x1 = this.vertical ? bounds.r : s;
111
- y1 = this.vertical ? s : bounds.t;
112
- x2 = this.vertical ? bounds.r + tickSize : s;
113
- y2 = this.vertical ? s : bounds.t - tickSize;
111
+ x1 = this.vertical ? bounds.r + tickOffset : s;
112
+ y1 = this.vertical ? s : bounds.t - tickOffset;
113
+ x2 = this.vertical ? bounds.r + tickOffset + tickSize : s;
114
+ y2 = this.vertical ? s : bounds.t - tickOffset - tickSize;
114
115
  } else {
115
- x1 = this.vertical ? bounds.l : s;
116
- y1 = this.vertical ? s : bounds.b;
117
- x2 = this.vertical ? bounds.l - tickSize : s;
118
- y2 = this.vertical ? s : bounds.b + tickSize;
116
+ x1 = this.vertical ? bounds.l - tickOffset : s;
117
+ y1 = this.vertical ? s : bounds.b + tickOffset;
118
+ x2 = this.vertical ? bounds.l - tickOffset - tickSize : s;
119
+ y2 = this.vertical ? s : bounds.b + tickOffset + tickSize;
119
120
  }
120
121
 
121
- t.push(`M ${x1} ${y1} L ${x2} ${y2}`);
122
+ if (!this.useGridlineTicks) t.push(`M ${x1} ${y1} L ${x2} ${y2}`);
122
123
 
123
124
  var x, y;
124
125
  let labelOffset =
@@ -155,6 +156,24 @@ export class Axis extends BoundedObject {
155
156
  }
156
157
 
157
158
  if (!data.hideTicks) {
159
+ if (this.useGridlineTicks) {
160
+ let gridlines = calculator.mapGridlines();
161
+ gridlines.forEach((s, i) => {
162
+ if (this.secondary) {
163
+ x1 = this.vertical ? bounds.r + tickOffset : s;
164
+ y1 = this.vertical ? s : bounds.t - tickOffset;
165
+ x2 = this.vertical ? bounds.r + tickOffset + tickSize : s;
166
+ y2 = this.vertical ? s : bounds.t - tickOffset - tickSize;
167
+ } else {
168
+ x1 = this.vertical ? bounds.l - tickOffset : s;
169
+ y1 = this.vertical ? s : bounds.b + tickOffset;
170
+ x2 = this.vertical ? bounds.l - tickOffset - tickSize : s;
171
+ y2 = this.vertical ? s : bounds.b + tickOffset + tickSize;
172
+ }
173
+ t.push(`M ${x1} ${y1} L ${x2} ${y2}`);
174
+ });
175
+ }
176
+
158
177
  res[1] = (
159
178
  <path
160
179
  key="ticks"
@@ -243,6 +262,7 @@ Axis.prototype.hideTicks = false;
243
262
  Axis.prototype.hideLine = false;
244
263
 
245
264
  Axis.prototype.tickSize = 3;
265
+ Axis.prototype.tickOffset = 0;
246
266
  Axis.prototype.minTickDistance = 25;
247
267
  Axis.prototype.minLabelDistanceVertical = 40;
248
268
  Axis.prototype.minLabelDistanceHorizontal = 50;
@@ -1,24 +1,27 @@
1
- import * as Cx from "../../core";
2
- import { AxisProps } from "./Axis";
3
-
4
- interface CategoryAxisProps extends AxisProps {
5
- /** Uniform axes provide exact size and offset for all entries, while non-uniform axes adapt their size and offset to the number of entries under each category. */
6
- uniform?: Cx.BooleanProp;
7
-
8
- /** Names corresponding the given `values`. For example, `values` may be 0 .. 11 and `names` could be Jan .. Dec. */
9
- names?: Cx.Prop<any[] | Cx.Config>;
10
-
11
- /** Values used to initialize the axis. If an object is provided, keys are used for values and values are used for names. */
12
- values?: Cx.Prop<any[] | Cx.Config>;
13
-
14
- /** Sometimes, there is not enough data and each category takes a lot of space. `minSize` can be used to add fake entries up to the specified number, so everything looks normal. */
15
- minSize?: Cx.NumberProp;
16
-
17
- /** Base CSS class to be applied to the element. Defaults to `categoryaxis`. */
18
- baseClass?: string;
19
-
20
- /** Output value that can be used to calculate chart dimensions based on discovered category values. */
21
- categoryCount?: Binding | Cx.AccessorChain<number> | Cx.GetSet<number>;
22
- }
23
-
24
- export class CategoryAxis extends Cx.Widget<CategoryAxisProps> {}
1
+ import * as Cx from "../../core";
2
+ import { AxisProps } from "./Axis";
3
+
4
+ interface CategoryAxisProps extends AxisProps {
5
+ /** Uniform axes provide exact size and offset for all entries, while non-uniform axes adapt their size and offset to the number of entries under each category. */
6
+ uniform?: Cx.BooleanProp;
7
+
8
+ /** Names corresponding the given `values`. For example, `values` may be 0 .. 11 and `names` could be Jan .. Dec. */
9
+ names?: Cx.Prop<any[] | Cx.Config>;
10
+
11
+ /** Values used to initialize the axis. If an object is provided, keys are used for values and values are used for names. */
12
+ values?: Cx.Prop<any[] | Cx.Config>;
13
+
14
+ /** Sometimes, there is not enough data and each category takes a lot of space. `minSize` can be used to add fake entries up to the specified number, so everything looks normal. */
15
+ minSize?: Cx.NumberProp;
16
+
17
+ /** Base CSS class to be applied to the element. Defaults to `categoryaxis`. */
18
+ baseClass?: string;
19
+
20
+ /** Output value that can be used to calculate chart dimensions based on discovered category values. */
21
+ categoryCount?: Binding | Cx.AccessorChain<number> | Cx.GetSet<number>;
22
+
23
+ /** Set to true to show ticks aligned with gridlines instead of labels. Default is false. */
24
+ useGridlineTicks?: boolean;
25
+ }
26
+
27
+ export class CategoryAxis extends Cx.Widget<CategoryAxisProps> {}