@nebula.js/sn-gauge 0.8.9 → 0.8.10

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/README.md CHANGED
@@ -1,19 +1,185 @@
1
1
  # sn-gauge
2
2
 
3
- ## !Experimental
3
+ ## A gauge for nebula.js
4
4
 
5
- A nebula.js supernova picasso gauge chart
5
+ The gauge is often used to present KPIs, that is a single measure value, in the form of
6
+ a radial gauge or a bar gauge.
6
7
 
7
- # Rendering tests
8
+ ![Gauge example](./assets/sn-gauge.png)
8
9
 
9
- Rendering tests are running playwright. Execute rendering tests with `pnpm test:e2e --headed`.
10
+ ## Requirements
10
11
 
11
- Rendering test compares a baseline snapshot with a current version of the same object. The output is then stored under `baselines`. It is important to take the baseline from the build in your PR and not your local baselines which is stored under `baselines-local`. The report with baselines can be found under summary under a link called test report.
12
+ Requires `@nebula.js/stardust` version `1.2.0` or later.
12
13
 
13
- You can use the action called update snapshot to trigger a commit into your branch that automatically updates the snapshots.
14
+ ## Installing
14
15
 
15
- 1. Go to actions tab.
16
- 2. Click on Build, validate, (release) workflow.
17
- 3. Open the Run workflow dropdown menu to the right.
18
- 4. Choose your branch and tick the update_snapshot.
19
- 5. Click Run workflow - now a commit will be done to your branch with updated snapshots.
16
+ If you use npm: `npm install @nebula.js/sn-gauge`.
17
+ You can also load through the script tag directly from
18
+ [https://unpkg.com](https://unpkg.com/@nebula.js/sn-gauge).
19
+
20
+ ## Usage
21
+
22
+ ```js
23
+ const nebula = embed(app, {
24
+ context: { theme: "light" },
25
+ types: [
26
+ {
27
+ name: "gauge",
28
+ load: () => Promise.resolve(gauge),
29
+ },
30
+ ],
31
+ });
32
+
33
+ nebula.render({
34
+ type: "gauge",
35
+ element: document.querySelector(".object"),
36
+ fields: ["=[A Sales $ with measure color]"],
37
+ options: { direction: "ltr", freeResize: true },
38
+ properties: {
39
+ measureAxis: {
40
+ min: 0,
41
+ max: 150000000,
42
+ },
43
+ useSegments: true,
44
+ color: { useBaseColors: "off" },
45
+ segmentInfo: {
46
+ limits: [
47
+ {
48
+ value: { qValueExpression: { qExpr: "Sum ([Sales Amount])*0.8" } },
49
+ gradient: false,
50
+ },
51
+ {
52
+ value: { qValueExpression: { qExpr: "Sum ([Sales Amount])*1.2" } },
53
+ gradient: false,
54
+ },
55
+ ],
56
+ paletteColors: [{ color: "#EE4266" }, { color: "#FFD23F" }, { color: "#337357" }],
57
+ },
58
+ },
59
+ });
60
+ ```
61
+
62
+ ## Options
63
+
64
+ - direction - ltr/rtl
65
+ - freeResize - in conjunction with snapshotData on layout,
66
+ lets the chart ignore size set on snapshotData
67
+
68
+ ## More examples
69
+
70
+ ### Radial gauge with label styles, right-to-left direction, and narrow axis spacing
71
+
72
+ You can decorate the labels of the radial gauge in
73
+ the previous example with more styles (font family and color),
74
+ by adding styling `"components"` into the `"properties"` of the gauge.
75
+
76
+ Also, for the sake of demonstration
77
+ the direction of the chart is changed from `"ltr"` to `"rtl"`,
78
+ and the axis spacing is made narrow (that is more ticks along the curved axis).
79
+
80
+ ![gauge style](assets/sn-gauge-label-styles-and-rtl.png)
81
+
82
+ ```js
83
+ nebula.render({
84
+ type: "gauge",
85
+ element: document.querySelector(".object"),
86
+ fields: ["=[A Sales $ with measure color]"],
87
+ options: { direction: "rtl" },
88
+ properties: {
89
+ measureAxis: {
90
+ min: 0,
91
+ max: 150000000,
92
+ spacing: 0.5,
93
+ },
94
+ useSegments: true,
95
+ color: { useBaseColors: "off" },
96
+ segmentInfo: {
97
+ limits: [
98
+ {
99
+ value: { qValueExpression: { qExpr: "Sum ([Sales Amount])*0.8" } },
100
+ gradient: false,
101
+ },
102
+ {
103
+ value: { qValueExpression: { qExpr: "Sum ([Sales Amount])*1.2" } },
104
+ gradient: false,
105
+ },
106
+ ],
107
+ paletteColors: [{ color: "#EE4266" }, { color: "#FFD23F" }, { color: "#337357" }],
108
+ },
109
+ components: [
110
+ {
111
+ key: "axis",
112
+ axis: {
113
+ title: {
114
+ fontFamily: "Montserrat, sans-serif",
115
+ color: { color: "#bb3e00" },
116
+ },
117
+ label: {
118
+ name: {
119
+ color: { color: "#657c6a" },
120
+ fontFamily: "Open Sans, sans-serif",
121
+ },
122
+ },
123
+ },
124
+ },
125
+ {
126
+ key: "value",
127
+ label: {
128
+ value: {
129
+ color: { color: "#f7ad45" },
130
+ fontFamily: "Roboto, sans-serif",
131
+ },
132
+ },
133
+ },
134
+ ],
135
+ },
136
+ });
137
+ ```
138
+
139
+ ### Horizontal bar gauge with segments and reference lines
140
+
141
+ You can combine segments and reference lines to clearly
142
+ put the measured value in context.
143
+
144
+ In the example below, you can compare the current sales value with
145
+ the value of last year and with the expected value.
146
+ The segments colors indicate which range the current value
147
+ falls into, and the reference lines and labels provide
148
+ information about the referenced values.
149
+
150
+ ![gauge segments and ref lines](assets/sn-gauge-ref-lines-and-segments.png)
151
+
152
+ ```js
153
+ nebula.render({
154
+ type: "gauge",
155
+ element: document.querySelector(".object"),
156
+ fields: ["=[A Sales $ with measure color]"],
157
+ properties: {
158
+ gaugetype: "bar",
159
+ measureAxis: { min: 0, max: 150000000 },
160
+ useSegments: true,
161
+ color: { useBaseColors: "off" },
162
+ segmentInfo: {
163
+ limits: [
164
+ { value: 91000000, gradient: false },
165
+ { value: 101000000, gradient: false },
166
+ ],
167
+ paletteColors: [{ color: "#EE4266" }, { color: "#FFD23F" }, { color: "#337357" }],
168
+ },
169
+ refLine: {
170
+ refLines: [
171
+ {
172
+ label: "Last year sales",
173
+ refLineExpr: { value: 91000000, label: "91000000" },
174
+ paletteColor: { color: "#cc3c5b" },
175
+ },
176
+ {
177
+ label: "Expectation",
178
+ refLineExpr: { value: 101000000, label: "101000000" },
179
+ paletteColor: { color: "#49bd2b" },
180
+ },
181
+ ],
182
+ },
183
+ },
184
+ });
185
+ ```
@@ -3,7 +3,7 @@
3
3
  "info": {
4
4
  "name": "@nebula.js/sn-gauge:properties",
5
5
  "description": "Gauge generic object definition",
6
- "version": "0.8.9",
6
+ "version": "0.8.10",
7
7
  "license": "MIT",
8
8
  "stability": "stable",
9
9
  "x-qlik-visibility": "public"