genesys-spark-chart-components 4.12.1-beta.1

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.
Files changed (142) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -0
  3. package/dist/cjs/genesys-chart-webcomponents.cjs.js +23 -0
  4. package/dist/cjs/gux-chart-column-beta.cjs.entry.js +140 -0
  5. package/dist/cjs/gux-chart-donut-beta.cjs.entry.js +229 -0
  6. package/dist/cjs/gux-chart-line-beta.cjs.entry.js +135 -0
  7. package/dist/cjs/gux-chart-pie-beta.cjs.entry.js +113 -0
  8. package/dist/cjs/gux-chart-scatter-plot-beta.cjs.entry.js +143 -0
  9. package/dist/cjs/gux-visualization-beta.cjs.entry.js +71953 -0
  10. package/dist/cjs/index-1e13a15f.js +1647 -0
  11. package/dist/cjs/index.cjs.js +2 -0
  12. package/dist/cjs/loader.cjs.js +13 -0
  13. package/dist/cjs/log-error-c46b4b4c.js +21 -0
  14. package/dist/cjs/usage-30f04ec3.js +208 -0
  15. package/dist/collection/collection-manifest.json +17 -0
  16. package/dist/collection/components/beta/gux-chart-column/gux-chart-column.css +13 -0
  17. package/dist/collection/components/beta/gux-chart-column/gux-chart-column.js +343 -0
  18. package/dist/collection/components/beta/gux-chart-column/gux-chart-column.locale.js +92 -0
  19. package/dist/collection/components/beta/gux-chart-column/tests/gux-column-chart.spec.js +22 -0
  20. package/dist/collection/components/beta/gux-chart-donut/gux-chart-donut.css +4 -0
  21. package/dist/collection/components/beta/gux-chart-donut/gux-chart-donut.js +575 -0
  22. package/dist/collection/components/beta/gux-chart-donut/tests/gux-chart-donut.spec.js +11 -0
  23. package/dist/collection/components/beta/gux-chart-line/gux-chart-line.css +4 -0
  24. package/dist/collection/components/beta/gux-chart-line/gux-chart-line.js +391 -0
  25. package/dist/collection/components/beta/gux-chart-line/gux-chart-line.locale.js +92 -0
  26. package/dist/collection/components/beta/gux-chart-line/tests/gux-chart-line.e2e.js +17 -0
  27. package/dist/collection/components/beta/gux-chart-line/tests/gux-chart-line.spec.js +22 -0
  28. package/dist/collection/components/beta/gux-chart-pie/gux-chart-pie.css +4 -0
  29. package/dist/collection/components/beta/gux-chart-pie/gux-chart-pie.js +284 -0
  30. package/dist/collection/components/beta/gux-chart-pie/tests/gux-chart-pie.spec.js +11 -0
  31. package/dist/collection/components/beta/gux-chart-scatter-plot/gux-chart-scatter-plot.css +4 -0
  32. package/dist/collection/components/beta/gux-chart-scatter-plot/gux-chart-scatter-plot.js +365 -0
  33. package/dist/collection/components/beta/gux-chart-scatter-plot/tests/gux-chart-scatter-plot.spec.js +33 -0
  34. package/dist/collection/components/beta/gux-visualization/gux-visualization.css +19 -0
  35. package/dist/collection/components/beta/gux-visualization/gux-visualization.js +143 -0
  36. package/dist/collection/components/beta/gux-visualization/gux-visualization.locale.js +92 -0
  37. package/dist/collection/components/beta/gux-visualization/tests/gux-visualization.e2e.js +31 -0
  38. package/dist/collection/components/beta/gux-visualization/tests/gux-visualization.spec.js +35 -0
  39. package/dist/collection/i18n/fetchResources.js +12 -0
  40. package/dist/collection/i18n/index.js +73 -0
  41. package/dist/collection/index.js +2 -0
  42. package/dist/collection/test/axeConfig.js +7 -0
  43. package/dist/collection/test/e2eTestUtils.js +20 -0
  44. package/dist/collection/test/jestMatcherUtils.js +1 -0
  45. package/dist/collection/test/setupAxeTests.js +75 -0
  46. package/dist/collection/test/setupTests.js +9 -0
  47. package/dist/collection/test/specTestUtils.js +10 -0
  48. package/dist/collection/utils/dom/get-closest-element.js +15 -0
  49. package/dist/collection/utils/error/log-error.js +6 -0
  50. package/dist/collection/utils/theme/color-palette.js +12 -0
  51. package/dist/collection/utils/tracking/usage.js +81 -0
  52. package/dist/collection/utils/tracking/usage.spec.js +121 -0
  53. package/dist/component-specs.json +187 -0
  54. package/dist/esm/genesys-chart-webcomponents.js +18 -0
  55. package/dist/esm/gux-chart-column-beta.entry.js +136 -0
  56. package/dist/esm/gux-chart-donut-beta.entry.js +225 -0
  57. package/dist/esm/gux-chart-line-beta.entry.js +131 -0
  58. package/dist/esm/gux-chart-pie-beta.entry.js +109 -0
  59. package/dist/esm/gux-chart-scatter-plot-beta.entry.js +139 -0
  60. package/dist/esm/gux-visualization-beta.entry.js +71949 -0
  61. package/dist/esm/index-701d93cf.js +1619 -0
  62. package/dist/esm/index.js +1 -0
  63. package/dist/esm/loader.js +9 -0
  64. package/dist/esm/log-error-0fc61f6f.js +18 -0
  65. package/dist/esm/polyfills/core-js.js +11 -0
  66. package/dist/esm/polyfills/dom.js +79 -0
  67. package/dist/esm/polyfills/es5-html-element.js +1 -0
  68. package/dist/esm/polyfills/index.js +34 -0
  69. package/dist/esm/polyfills/system.js +6 -0
  70. package/dist/esm/usage-61eee3bd.js +206 -0
  71. package/dist/genesys-chart-webcomponents/genesys-chart-webcomponents.css +1 -0
  72. package/dist/genesys-chart-webcomponents/genesys-chart-webcomponents.esm.js +1 -0
  73. package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.ar.json +1 -0
  74. package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.cs.json +1 -0
  75. package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.da.json +1 -0
  76. package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.de.json +1 -0
  77. package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.en.json +1 -0
  78. package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.es-es.json +1 -0
  79. package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.es.json +1 -0
  80. package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.fi.json +1 -0
  81. package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.fr-ca.json +1 -0
  82. package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.fr.json +1 -0
  83. package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.he.json +1 -0
  84. package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.it.json +1 -0
  85. package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.ja.json +1 -0
  86. package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.ko.json +1 -0
  87. package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.nl.json +1 -0
  88. package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.no.json +1 -0
  89. package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.pl.json +1 -0
  90. package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.pt-br.json +1 -0
  91. package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.pt-pt.json +1 -0
  92. package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.ru.json +1 -0
  93. package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.sv.json +1 -0
  94. package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.th.json +1 -0
  95. package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.tr.json +1 -0
  96. package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.uk.json +1 -0
  97. package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.zh-cn.json +1 -0
  98. package/dist/genesys-chart-webcomponents/i18n/genesys-webcomponents.i18n.zh-tw.json +1 -0
  99. package/dist/genesys-chart-webcomponents/index.esm.js +0 -0
  100. package/dist/genesys-chart-webcomponents/p-137f5b8f.entry.js +1 -0
  101. package/dist/genesys-chart-webcomponents/p-3e4b3dbc.js +2 -0
  102. package/dist/genesys-chart-webcomponents/p-82f0ea01.js +1 -0
  103. package/dist/genesys-chart-webcomponents/p-97c45977.js +1 -0
  104. package/dist/genesys-chart-webcomponents/p-b5179379.entry.js +1 -0
  105. package/dist/genesys-chart-webcomponents/p-b901e9e0.entry.js +11 -0
  106. package/dist/genesys-chart-webcomponents/p-c3aa8578.entry.js +1 -0
  107. package/dist/genesys-chart-webcomponents/p-d4a346df.entry.js +1 -0
  108. package/dist/genesys-chart-webcomponents/p-d9928f8c.entry.js +1 -0
  109. package/dist/index.cjs.js +1 -0
  110. package/dist/index.js +1 -0
  111. package/dist/loader/cdn.js +3 -0
  112. package/dist/loader/index.cjs.js +3 -0
  113. package/dist/loader/index.d.ts +21 -0
  114. package/dist/loader/index.es2017.js +3 -0
  115. package/dist/loader/index.js +4 -0
  116. package/dist/loader/package.json +11 -0
  117. package/dist/stencil-wrapper.js +58 -0
  118. package/dist/types/components/beta/gux-chart-column/gux-chart-column.d.ts +49 -0
  119. package/dist/types/components/beta/gux-chart-column/gux-chart-column.locale.d.ts +22 -0
  120. package/dist/types/components/beta/gux-chart-donut/gux-chart-donut.d.ts +34 -0
  121. package/dist/types/components/beta/gux-chart-line/gux-chart-line.d.ts +48 -0
  122. package/dist/types/components/beta/gux-chart-line/gux-chart-line.locale.d.ts +22 -0
  123. package/dist/types/components/beta/gux-chart-pie/gux-chart-pie.d.ts +23 -0
  124. package/dist/types/components/beta/gux-chart-scatter-plot/gux-chart-scatter-plot.d.ts +52 -0
  125. package/dist/types/components/beta/gux-visualization/gux-visualization.d.ts +17 -0
  126. package/dist/types/components/beta/gux-visualization/gux-visualization.locale.d.ts +22 -0
  127. package/dist/types/components.d.ts +480 -0
  128. package/dist/types/i18n/fetchResources.d.ts +11 -0
  129. package/dist/types/i18n/index.d.ts +9 -0
  130. package/dist/types/index.d.ts +3 -0
  131. package/dist/types/stencil-public-runtime.d.ts +1671 -0
  132. package/dist/types/stencil-wrapper.d.ts +2 -0
  133. package/dist/types/test/axeConfig.d.ts +6 -0
  134. package/dist/types/test/e2eTestUtils.d.ts +9 -0
  135. package/dist/types/test/jestMatcherUtils.d.ts +8 -0
  136. package/dist/types/test/specTestUtils.d.ts +2 -0
  137. package/dist/types/typings.d.ts +4 -0
  138. package/dist/types/utils/dom/get-closest-element.d.ts +1 -0
  139. package/dist/types/utils/error/log-error.d.ts +2 -0
  140. package/dist/types/utils/theme/color-palette.d.ts +1 -0
  141. package/dist/types/utils/tracking/usage.d.ts +27 -0
  142. package/package.json +118 -0
@@ -0,0 +1,284 @@
1
+ /* eslint-disable @typescript-eslint/no-unsafe-member-access */
2
+ import { h } from "@stencil/core";
3
+ import { trackComponent } from "../../../utils/tracking/usage";
4
+ import { logError } from "../../../utils/error/log-error";
5
+ import { VISUALIZATION_COLORS } from "../../../utils/theme/color-palette";
6
+ const DEFAULT_COLOR_FIELD_NAME = 'category';
7
+ const DEFAULT_LABEL_FIELD_NAME = 'value';
8
+ export class GuxPieChart {
9
+ constructor() {
10
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
+ this.baseChartSpec = {
12
+ $schema: 'https://vega.github.io/schema/vega-lite/v5.json',
13
+ config: {
14
+ legend: {
15
+ symbolType: 'circle'
16
+ }
17
+ },
18
+ encoding: {
19
+ theta: { field: 'value', type: 'quantitative', stack: true },
20
+ color: {
21
+ field: DEFAULT_COLOR_FIELD_NAME,
22
+ type: 'nominal',
23
+ scale: { range: VISUALIZATION_COLORS },
24
+ legend: null
25
+ },
26
+ tooltip: { aggregate: 'count', type: 'quantitative' }
27
+ },
28
+ layer: [
29
+ {
30
+ mark: { type: 'arc', outerRadius: 80 }
31
+ },
32
+ {
33
+ mark: { type: 'text', radius: 90 },
34
+ encoding: {
35
+ text: { field: DEFAULT_LABEL_FIELD_NAME, type: 'quantitative' }
36
+ }
37
+ }
38
+ ],
39
+ view: { stroke: null }
40
+ };
41
+ this.chartData = undefined;
42
+ this.includeLegend = undefined;
43
+ this.legendPosition = 'right';
44
+ this.legendTitle = undefined;
45
+ this.colorFieldName = undefined;
46
+ this.outerRadius = undefined;
47
+ this.labelRadius = undefined;
48
+ this.labelField = undefined;
49
+ this.embedOptions = undefined;
50
+ }
51
+ parseData() {
52
+ if (!this.outerRadius) {
53
+ logError(this.root, 'requires outer-radius');
54
+ }
55
+ let chartData = {};
56
+ if (this.chartData) {
57
+ chartData = { data: this.chartData };
58
+ }
59
+ if (this.includeLegend) {
60
+ this.baseChartSpec.encoding.color.legend = true;
61
+ }
62
+ if (this.legendPosition) {
63
+ this.baseChartSpec.config.legend.orient = this.legendPosition;
64
+ }
65
+ const colorFieldName = this.colorFieldName || DEFAULT_COLOR_FIELD_NAME;
66
+ if (colorFieldName) {
67
+ this.baseChartSpec.encoding.color.field = colorFieldName;
68
+ }
69
+ const legendTitle = this.legendTitle;
70
+ if (legendTitle) {
71
+ this.baseChartSpec.encoding.color.title = legendTitle;
72
+ }
73
+ const outerRadius = this.outerRadius;
74
+ this.baseChartSpec.layer = [
75
+ {
76
+ mark: { type: 'arc', outerRadius }
77
+ }
78
+ ];
79
+ const labelRadius = this.labelRadius;
80
+ const labelField = this.labelField || DEFAULT_LABEL_FIELD_NAME;
81
+ if (labelRadius) {
82
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call
83
+ this.baseChartSpec.layer.push({
84
+ mark: { type: 'text', radius: labelRadius },
85
+ encoding: {
86
+ text: { field: labelField, type: 'quantitative' }
87
+ }
88
+ });
89
+ }
90
+ const spec = Object.assign(this.baseChartSpec, chartData);
91
+ this.visualizationSpec = spec;
92
+ }
93
+ componentWillLoad() {
94
+ trackComponent(this.root);
95
+ this.parseData();
96
+ }
97
+ render() {
98
+ return (h("gux-visualization-beta", { visualizationSpec: this.visualizationSpec }));
99
+ }
100
+ static get is() { return "gux-chart-pie-beta"; }
101
+ static get encapsulation() { return "shadow"; }
102
+ static get originalStyleUrls() {
103
+ return {
104
+ "$": ["gux-chart-pie.scss"]
105
+ };
106
+ }
107
+ static get styleUrls() {
108
+ return {
109
+ "$": ["gux-chart-pie.css"]
110
+ };
111
+ }
112
+ static get properties() {
113
+ return {
114
+ "chartData": {
115
+ "type": "unknown",
116
+ "mutable": false,
117
+ "complexType": {
118
+ "original": "Record<string, any>",
119
+ "resolved": "{ [x: string]: any; }",
120
+ "references": {
121
+ "Record": {
122
+ "location": "global",
123
+ "id": "global::Record"
124
+ }
125
+ }
126
+ },
127
+ "required": false,
128
+ "optional": false,
129
+ "docs": {
130
+ "tags": [],
131
+ "text": "Data to be rendered in the chart.\nData field names must match the values you set in xFieldName and yFieldName"
132
+ }
133
+ },
134
+ "includeLegend": {
135
+ "type": "boolean",
136
+ "mutable": false,
137
+ "complexType": {
138
+ "original": "boolean",
139
+ "resolved": "boolean",
140
+ "references": {}
141
+ },
142
+ "required": false,
143
+ "optional": false,
144
+ "docs": {
145
+ "tags": [],
146
+ "text": ""
147
+ },
148
+ "attribute": "include-legend",
149
+ "reflect": false
150
+ },
151
+ "legendPosition": {
152
+ "type": "string",
153
+ "mutable": false,
154
+ "complexType": {
155
+ "original": "| 'left'\n | 'right'\n | 'top'\n | 'bottom'\n | 'top-left'\n | 'top-right'\n | 'bottom-left'\n | 'bottom-right'\n | 'none'",
156
+ "resolved": "\"bottom\" | \"bottom-left\" | \"bottom-right\" | \"left\" | \"none\" | \"right\" | \"top\" | \"top-left\" | \"top-right\"",
157
+ "references": {}
158
+ },
159
+ "required": false,
160
+ "optional": false,
161
+ "docs": {
162
+ "tags": [],
163
+ "text": ""
164
+ },
165
+ "attribute": "legend-position",
166
+ "reflect": false,
167
+ "defaultValue": "'right'"
168
+ },
169
+ "legendTitle": {
170
+ "type": "string",
171
+ "mutable": false,
172
+ "complexType": {
173
+ "original": "string",
174
+ "resolved": "string",
175
+ "references": {}
176
+ },
177
+ "required": false,
178
+ "optional": false,
179
+ "docs": {
180
+ "tags": [],
181
+ "text": ""
182
+ },
183
+ "attribute": "legend-title",
184
+ "reflect": false
185
+ },
186
+ "colorFieldName": {
187
+ "type": "string",
188
+ "mutable": false,
189
+ "complexType": {
190
+ "original": "string",
191
+ "resolved": "string",
192
+ "references": {}
193
+ },
194
+ "required": false,
195
+ "optional": false,
196
+ "docs": {
197
+ "tags": [],
198
+ "text": ""
199
+ },
200
+ "attribute": "color-field-name",
201
+ "reflect": false
202
+ },
203
+ "outerRadius": {
204
+ "type": "number",
205
+ "mutable": false,
206
+ "complexType": {
207
+ "original": "number",
208
+ "resolved": "number",
209
+ "references": {}
210
+ },
211
+ "required": false,
212
+ "optional": false,
213
+ "docs": {
214
+ "tags": [],
215
+ "text": ""
216
+ },
217
+ "attribute": "outer-radius",
218
+ "reflect": false
219
+ },
220
+ "labelRadius": {
221
+ "type": "number",
222
+ "mutable": false,
223
+ "complexType": {
224
+ "original": "number",
225
+ "resolved": "number",
226
+ "references": {}
227
+ },
228
+ "required": false,
229
+ "optional": false,
230
+ "docs": {
231
+ "tags": [],
232
+ "text": ""
233
+ },
234
+ "attribute": "label-radius",
235
+ "reflect": false
236
+ },
237
+ "labelField": {
238
+ "type": "string",
239
+ "mutable": false,
240
+ "complexType": {
241
+ "original": "string",
242
+ "resolved": "string",
243
+ "references": {}
244
+ },
245
+ "required": false,
246
+ "optional": false,
247
+ "docs": {
248
+ "tags": [],
249
+ "text": ""
250
+ },
251
+ "attribute": "label-field",
252
+ "reflect": false
253
+ },
254
+ "embedOptions": {
255
+ "type": "unknown",
256
+ "mutable": false,
257
+ "complexType": {
258
+ "original": "EmbedOptions",
259
+ "resolved": "EmbedOptions<string, Renderers>",
260
+ "references": {
261
+ "EmbedOptions": {
262
+ "location": "import",
263
+ "path": "vega-embed",
264
+ "id": "../../node_modules/vega-embed/build/vega-embed.module.d.ts::EmbedOptions"
265
+ }
266
+ }
267
+ },
268
+ "required": false,
269
+ "optional": false,
270
+ "docs": {
271
+ "tags": [],
272
+ "text": ""
273
+ }
274
+ }
275
+ };
276
+ }
277
+ static get elementRef() { return "root"; }
278
+ static get watchers() {
279
+ return [{
280
+ "propName": "chartData",
281
+ "methodName": "parseData"
282
+ }];
283
+ }
284
+ }
@@ -0,0 +1,11 @@
1
+ import { newSpecPage } from "../../../../test/specTestUtils";
2
+ import { GuxPieChart } from "../gux-chart-pie";
3
+ const components = [GuxPieChart];
4
+ const language = 'en';
5
+ describe('gux-chart-pie-beta', () => {
6
+ it('should build', async () => {
7
+ const html = '<gux-chart-pie-beta outer-radius="80"></gux-chart-pie-beta>';
8
+ const page = await newSpecPage({ components, html, language });
9
+ expect(page.rootInstance).toBeInstanceOf(GuxPieChart);
10
+ });
11
+ });
@@ -0,0 +1,4 @@
1
+ gux-visualization-beta {
2
+ height: fit-content;
3
+ color: #2e394c;
4
+ }
@@ -0,0 +1,365 @@
1
+ /* eslint-disable @typescript-eslint/no-unsafe-member-access */
2
+ import { h } from "@stencil/core";
3
+ import { trackComponent } from "../../../utils/tracking/usage";
4
+ import { VISUALIZATION_COLORS } from "../../../utils/theme/color-palette";
5
+ import { logError } from "../../../utils/error/log-error";
6
+ const DEFAULT_COLOR_FIELD_NAME = 'category';
7
+ export class GuxScatterPlotChart {
8
+ constructor() {
9
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
+ this.baseChartSpec = {
11
+ $schema: 'https://vega.github.io/schema/vega-lite/v5.json',
12
+ params: [
13
+ {
14
+ name: 'onHover',
15
+ select: { type: 'point', on: 'mouseover' }
16
+ }
17
+ ],
18
+ config: {
19
+ axis: {
20
+ ticks: false,
21
+ titlePadding: 8,
22
+ gridColor: '#F6F7F9'
23
+ },
24
+ axisX: {
25
+ labelAngle: 0,
26
+ grid: true
27
+ },
28
+ legend: {
29
+ symbolType: 'circle'
30
+ }
31
+ },
32
+ width: { step: 40 },
33
+ encoding: {
34
+ x: { type: 'nominal' },
35
+ y: { type: 'quantitative' },
36
+ color: {
37
+ field: DEFAULT_COLOR_FIELD_NAME,
38
+ type: 'nominal',
39
+ scale: { range: VISUALIZATION_COLORS },
40
+ legend: null
41
+ },
42
+ size: {
43
+ condition: [
44
+ {
45
+ param: 'onHover',
46
+ empty: false,
47
+ value: 100
48
+ }
49
+ ],
50
+ value: 40
51
+ }
52
+ }
53
+ };
54
+ this.chartData = undefined;
55
+ this.xTickLabelSlant = undefined;
56
+ this.includeLegend = undefined;
57
+ this.legendPosition = 'right';
58
+ this.xFieldName = undefined;
59
+ this.xAxisTitle = undefined;
60
+ this.yFieldName = undefined;
61
+ this.yAxisTitle = undefined;
62
+ this.legendTitle = undefined;
63
+ this.colorFieldName = undefined;
64
+ this.useShape = undefined;
65
+ this.embedOptions = undefined;
66
+ }
67
+ parseData() {
68
+ if (!this.xFieldName || !this.yFieldName) {
69
+ logError(this.root, 'requires x-field-name and y-field-name');
70
+ }
71
+ let chartData = {};
72
+ if (this.chartData) {
73
+ chartData = { data: this.chartData };
74
+ }
75
+ if (this.xTickLabelSlant) {
76
+ this.baseChartSpec.config.axisX.labelAngle = -45;
77
+ }
78
+ if (this.legendPosition) {
79
+ this.baseChartSpec.config.legend.orient = this.legendPosition;
80
+ }
81
+ const xFieldName = this.xFieldName;
82
+ const xAxisTitle = this.xAxisTitle;
83
+ const yFieldName = this.yFieldName;
84
+ const yAxisTitle = this.yAxisTitle;
85
+ const legendTitle = this.legendTitle;
86
+ const useShape = this.useShape || 'circle';
87
+ const colorFieldName = this.colorFieldName || DEFAULT_COLOR_FIELD_NAME;
88
+ if (this.includeLegend) {
89
+ this.baseChartSpec.encoding.color.legend = true;
90
+ }
91
+ if (xFieldName) {
92
+ this.baseChartSpec.encoding.x.field = xFieldName;
93
+ }
94
+ if (xAxisTitle) {
95
+ this.baseChartSpec.encoding.x.title = xAxisTitle;
96
+ }
97
+ if (yFieldName) {
98
+ this.baseChartSpec.encoding.y.field = yFieldName;
99
+ }
100
+ if (yAxisTitle) {
101
+ this.baseChartSpec.encoding.y.title = yAxisTitle;
102
+ }
103
+ if (colorFieldName) {
104
+ this.baseChartSpec.encoding.color.field = colorFieldName;
105
+ }
106
+ if (legendTitle) {
107
+ this.baseChartSpec.encoding.color.title = legendTitle;
108
+ }
109
+ this.baseChartSpec.mark = { type: useShape, filled: true };
110
+ this.baseChartSpec.config.legend.symbolType = useShape;
111
+ this.baseChartSpec.encoding.shape = {
112
+ field: colorFieldName,
113
+ type: 'nominal'
114
+ };
115
+ this.baseChartSpec.encoding.tooltip = [
116
+ { field: xFieldName, type: 'nominal', title: xAxisTitle },
117
+ { field: yFieldName, type: 'quantitative', title: yAxisTitle },
118
+ { field: colorFieldName, type: 'nominal', title: legendTitle }
119
+ ];
120
+ const spec = Object.assign(this.baseChartSpec, chartData);
121
+ this.visualizationSpec = spec;
122
+ }
123
+ componentWillLoad() {
124
+ trackComponent(this.root);
125
+ this.parseData();
126
+ }
127
+ render() {
128
+ return (h("gux-visualization-beta", { visualizationSpec: this.visualizationSpec }));
129
+ }
130
+ static get is() { return "gux-chart-scatter-plot-beta"; }
131
+ static get encapsulation() { return "shadow"; }
132
+ static get originalStyleUrls() {
133
+ return {
134
+ "$": ["gux-chart-scatter-plot.scss"]
135
+ };
136
+ }
137
+ static get styleUrls() {
138
+ return {
139
+ "$": ["gux-chart-scatter-plot.css"]
140
+ };
141
+ }
142
+ static get properties() {
143
+ return {
144
+ "chartData": {
145
+ "type": "unknown",
146
+ "mutable": false,
147
+ "complexType": {
148
+ "original": "Record<string, any>",
149
+ "resolved": "{ [x: string]: any; }",
150
+ "references": {
151
+ "Record": {
152
+ "location": "global",
153
+ "id": "global::Record"
154
+ }
155
+ }
156
+ },
157
+ "required": false,
158
+ "optional": false,
159
+ "docs": {
160
+ "tags": [],
161
+ "text": "Data to be rendered in the chart.\nData field names must match the values you set in xFieldName and yFieldName"
162
+ }
163
+ },
164
+ "xTickLabelSlant": {
165
+ "type": "boolean",
166
+ "mutable": false,
167
+ "complexType": {
168
+ "original": "boolean",
169
+ "resolved": "boolean",
170
+ "references": {}
171
+ },
172
+ "required": false,
173
+ "optional": false,
174
+ "docs": {
175
+ "tags": [],
176
+ "text": "If true, then make Axis tick label 45 degrees"
177
+ },
178
+ "attribute": "x-tick-label-slant",
179
+ "reflect": false
180
+ },
181
+ "includeLegend": {
182
+ "type": "boolean",
183
+ "mutable": false,
184
+ "complexType": {
185
+ "original": "boolean",
186
+ "resolved": "boolean",
187
+ "references": {}
188
+ },
189
+ "required": false,
190
+ "optional": false,
191
+ "docs": {
192
+ "tags": [],
193
+ "text": ""
194
+ },
195
+ "attribute": "include-legend",
196
+ "reflect": false
197
+ },
198
+ "legendPosition": {
199
+ "type": "string",
200
+ "mutable": false,
201
+ "complexType": {
202
+ "original": "| 'left'\n | 'right'\n | 'top'\n | 'bottom'\n | 'top-left'\n | 'top-right'\n | 'bottom-left'\n | 'bottom-right'\n | 'none'",
203
+ "resolved": "\"bottom\" | \"bottom-left\" | \"bottom-right\" | \"left\" | \"none\" | \"right\" | \"top\" | \"top-left\" | \"top-right\"",
204
+ "references": {}
205
+ },
206
+ "required": false,
207
+ "optional": false,
208
+ "docs": {
209
+ "tags": [],
210
+ "text": ""
211
+ },
212
+ "attribute": "legend-position",
213
+ "reflect": false,
214
+ "defaultValue": "'right'"
215
+ },
216
+ "xFieldName": {
217
+ "type": "string",
218
+ "mutable": false,
219
+ "complexType": {
220
+ "original": "string",
221
+ "resolved": "string",
222
+ "references": {}
223
+ },
224
+ "required": false,
225
+ "optional": false,
226
+ "docs": {
227
+ "tags": [],
228
+ "text": "Name for the data field to use to populate the chart's x-axis\ne.g. xFieldName of \"category\" will map any \"category\" fields in chartData to the x-axis"
229
+ },
230
+ "attribute": "x-field-name",
231
+ "reflect": false
232
+ },
233
+ "xAxisTitle": {
234
+ "type": "string",
235
+ "mutable": false,
236
+ "complexType": {
237
+ "original": "string",
238
+ "resolved": "string",
239
+ "references": {}
240
+ },
241
+ "required": false,
242
+ "optional": false,
243
+ "docs": {
244
+ "tags": [],
245
+ "text": "Title to display along the x-axis"
246
+ },
247
+ "attribute": "x-axis-title",
248
+ "reflect": false
249
+ },
250
+ "yFieldName": {
251
+ "type": "string",
252
+ "mutable": false,
253
+ "complexType": {
254
+ "original": "string",
255
+ "resolved": "string",
256
+ "references": {}
257
+ },
258
+ "required": false,
259
+ "optional": false,
260
+ "docs": {
261
+ "tags": [],
262
+ "text": "Name for the data field to use to populate the chart's x-axis\ne.g. yFieldName of \"value\" will map any \"value\" fields in chartData to the y-axis"
263
+ },
264
+ "attribute": "y-field-name",
265
+ "reflect": false
266
+ },
267
+ "yAxisTitle": {
268
+ "type": "string",
269
+ "mutable": false,
270
+ "complexType": {
271
+ "original": "string",
272
+ "resolved": "string",
273
+ "references": {}
274
+ },
275
+ "required": false,
276
+ "optional": false,
277
+ "docs": {
278
+ "tags": [],
279
+ "text": "Title to display along the y-axis"
280
+ },
281
+ "attribute": "y-axis-title",
282
+ "reflect": false
283
+ },
284
+ "legendTitle": {
285
+ "type": "string",
286
+ "mutable": false,
287
+ "complexType": {
288
+ "original": "string",
289
+ "resolved": "string",
290
+ "references": {}
291
+ },
292
+ "required": false,
293
+ "optional": false,
294
+ "docs": {
295
+ "tags": [],
296
+ "text": "Title to display above the optional legend"
297
+ },
298
+ "attribute": "legend-title",
299
+ "reflect": false
300
+ },
301
+ "colorFieldName": {
302
+ "type": "string",
303
+ "mutable": false,
304
+ "complexType": {
305
+ "original": "string",
306
+ "resolved": "string",
307
+ "references": {}
308
+ },
309
+ "required": false,
310
+ "optional": false,
311
+ "docs": {
312
+ "tags": [],
313
+ "text": "Type of category to plot in the chart"
314
+ },
315
+ "attribute": "color-field-name",
316
+ "reflect": false
317
+ },
318
+ "useShape": {
319
+ "type": "string",
320
+ "mutable": false,
321
+ "complexType": {
322
+ "original": "string",
323
+ "resolved": "string",
324
+ "references": {}
325
+ },
326
+ "required": false,
327
+ "optional": false,
328
+ "docs": {
329
+ "tags": [],
330
+ "text": "The shape of the plotting in the chart - Square, Circle and Point"
331
+ },
332
+ "attribute": "use-shape",
333
+ "reflect": false
334
+ },
335
+ "embedOptions": {
336
+ "type": "unknown",
337
+ "mutable": false,
338
+ "complexType": {
339
+ "original": "EmbedOptions",
340
+ "resolved": "EmbedOptions<string, Renderers>",
341
+ "references": {
342
+ "EmbedOptions": {
343
+ "location": "import",
344
+ "path": "vega-embed",
345
+ "id": "../../node_modules/vega-embed/build/vega-embed.module.d.ts::EmbedOptions"
346
+ }
347
+ }
348
+ },
349
+ "required": false,
350
+ "optional": false,
351
+ "docs": {
352
+ "tags": [],
353
+ "text": ""
354
+ }
355
+ }
356
+ };
357
+ }
358
+ static get elementRef() { return "root"; }
359
+ static get watchers() {
360
+ return [{
361
+ "propName": "chartData",
362
+ "methodName": "parseData"
363
+ }];
364
+ }
365
+ }
@@ -0,0 +1,33 @@
1
+ import { newSpecPage } from "../../../../test/specTestUtils";
2
+ import { GuxScatterPlotChart } from "../gux-chart-scatter-plot";
3
+ const components = [GuxScatterPlotChart];
4
+ const language = 'en';
5
+ describe('gux-chart-scatter-plot-beta', () => {
6
+ it('should build', async () => {
7
+ const html = '<gux-chart-scatter-plot-beta x-field-name="date" y-field-name="value"></gux-chart-scatter-plot-beta>';
8
+ const page = await newSpecPage({ components, html, language });
9
+ expect(page.rootInstance).toBeInstanceOf(GuxScatterPlotChart);
10
+ });
11
+ it('should reflect the shape user has chosen', async () => {
12
+ let html = '<gux-chart-scatter-plot-beta x-field-name="date" y-field-name="value"></gux-chart-scatter-plot-beta>';
13
+ let page = await newSpecPage({ components, html, language });
14
+ expect(page.rootInstance.useShape).toBeUndefined();
15
+ expect(page.rootInstance.baseChartSpec.mark.type).toBe('circle');
16
+ html =
17
+ '<gux-chart-scatter-plot-beta x-field-name="date" y-field-name="value" use-shape="square"></gux-chart-scatter-plot-beta>';
18
+ page = await newSpecPage({ components, html, language });
19
+ expect(page.rootInstance.useShape).toBeTruthy();
20
+ expect(page.rootInstance.baseChartSpec.mark.type).toBe('square');
21
+ });
22
+ it('should reflect user option to make slant x axis tick labels', async () => {
23
+ let html = '<gux-chart-scatter-plot-beta x-field-name="date" y-field-name="value"></gux-chart-scatter-plot-beta>';
24
+ let page = await newSpecPage({ components, html, language });
25
+ expect(page.rootInstance.xTickLabelSlant).toBeUndefined();
26
+ expect(page.rootInstance.baseChartSpec.config.axisX.labelAngle).toBe(0);
27
+ html =
28
+ '<gux-chart-scatter-plot-beta x-field-name="date" y-field-name="value" x-tick-label-slant="true"></gux-chart-scatter-plot-beta>';
29
+ page = await newSpecPage({ components, html, language });
30
+ expect(page.rootInstance.xTickLabelSlant).toBeTruthy();
31
+ expect(page.rootInstance.baseChartSpec.config.axisX.labelAngle).toBe(-45);
32
+ });
33
+ });