@iamproperty/components 5.7.1-beta6 → 6.0.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.
- package/assets/css/components/barchart.component.css +1 -1
- package/assets/css/components/barchart.component.css.map +1 -1
- package/assets/css/components/charts.module.css +1 -1
- package/assets/css/components/charts.module.css.map +1 -1
- package/assets/js/components/_global.js +32 -0
- package/assets/js/components/accordion/accordion.component.min.js +1 -1
- package/assets/js/components/actionbar/actionbar.component.min.js +1 -1
- package/assets/js/components/address-lookup/address-lookup.component.min.js +1 -1
- package/assets/js/components/applied-filters/applied-filters.component.min.js +1 -1
- package/assets/js/components/barchart/barchart.component.js +6 -7
- package/assets/js/components/barchart/barchart.component.min.js +4 -4
- package/assets/js/components/barchart/barchart.component.min.js.map +1 -1
- package/assets/js/components/card/card.component.js +1 -1
- package/assets/js/components/card/card.component.min.js +2 -2
- package/assets/js/components/card/card.component.min.js.map +1 -1
- package/assets/js/components/carousel/carousel.component.min.js +1 -1
- package/assets/js/components/collapsible-side/collapsible-side.component.min.js +1 -1
- package/assets/js/components/fileupload/fileupload.component.min.js +1 -1
- package/assets/js/components/filterlist/filterlist.component.min.js +1 -1
- package/assets/js/components/header/header.component.min.js +1 -1
- package/assets/js/components/inline-edit/inline-edit.component.min.js +1 -1
- package/assets/js/components/marketing/marketing.component.min.js +1 -1
- package/assets/js/components/multiselect/multiselect.component.min.js +1 -1
- package/assets/js/components/nav/nav.component.min.js +1 -1
- package/assets/js/components/notification/notification.component.min.js +1 -1
- package/assets/js/components/pagination/pagination.component.min.js +1 -1
- package/assets/js/components/search/search.component.min.js +1 -1
- package/assets/js/components/slider/slider.component.min.js +1 -1
- package/assets/js/components/table/table.component.min.js +1 -1
- package/assets/js/components/tabs/tabs.component.min.js +1 -1
- package/assets/js/dynamic.min.js +1 -1
- package/assets/js/modules/chart.module.js +25 -60
- package/assets/js/scripts.bundle.js +2 -2
- package/assets/js/scripts.bundle.js.map +1 -1
- package/assets/js/scripts.bundle.min.js +2 -2
- package/assets/js/scripts.bundle.min.js.map +1 -1
- package/assets/js/tests/chart.spec.js +57 -0
- package/assets/sass/components/charts.module.scss +13 -4
- package/assets/ts/components/_global.ts +40 -0
- package/assets/ts/components/barchart/barchart.component.ts +7 -17
- package/assets/ts/components/card/card.component.ts +1 -1
- package/assets/ts/modules/chart.module.ts +25 -74
- package/assets/ts/tests/chart.spec.ts +77 -0
- package/dist/components.es.js +11 -11
- package/dist/components.umd.js +12 -12
- package/package.json +1 -1
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import '@testing-library/jest-dom';
|
|
3
|
+
import { getChartData } from "../modules/chart.module.js";
|
|
4
|
+
import "expect-puppeteer";
|
|
5
|
+
import iamBarChart from "../components/barchart/barchart.component.js";
|
|
6
|
+
describe('The bar chart component', () => {
|
|
7
|
+
if (!window.customElements.get(`iam-barchart`))
|
|
8
|
+
window.customElements.define(`iam-barchart`, iamBarChart);
|
|
9
|
+
document.body.innerHTML = `
|
|
10
|
+
<iam-barchart>
|
|
11
|
+
<table>
|
|
12
|
+
<thead>
|
|
13
|
+
<tr>
|
|
14
|
+
<th>Items</th>
|
|
15
|
+
<th>Value</th>
|
|
16
|
+
</tr>
|
|
17
|
+
</thead>
|
|
18
|
+
<tbody>
|
|
19
|
+
<tr>
|
|
20
|
+
<td>Item 1</td>
|
|
21
|
+
<td>300</td>
|
|
22
|
+
</tr>
|
|
23
|
+
<tr>
|
|
24
|
+
<td>Item 2</td>
|
|
25
|
+
<td>150</td>
|
|
26
|
+
</tr>
|
|
27
|
+
<tr>
|
|
28
|
+
<td>Item 3</td>
|
|
29
|
+
<td>100</td>
|
|
30
|
+
</tr>
|
|
31
|
+
</tbody>
|
|
32
|
+
</table>
|
|
33
|
+
</iam-barchart>`;
|
|
34
|
+
test('should create the min attribute as 0', () => {
|
|
35
|
+
let component = document.querySelector('iam-barchart');
|
|
36
|
+
let { min } = getChartData(component);
|
|
37
|
+
expect(min).toEqual(0);
|
|
38
|
+
});
|
|
39
|
+
test('should equal the largest single value', () => {
|
|
40
|
+
let component = document.querySelector('iam-barchart');
|
|
41
|
+
let { max } = getChartData(component);
|
|
42
|
+
expect(max).toEqual(300);
|
|
43
|
+
});
|
|
44
|
+
test('should equal the largest single value', () => {
|
|
45
|
+
let component = document.querySelector('iam-barchart');
|
|
46
|
+
let { max } = getChartData(component);
|
|
47
|
+
expect(max).toEqual(300);
|
|
48
|
+
});
|
|
49
|
+
test('should have the class of .chart--fit-content added as there is less than 10 bars', () => {
|
|
50
|
+
let component = document.querySelector('iam-barchart');
|
|
51
|
+
expect(component.classList).toContain("chart--fit-content");
|
|
52
|
+
});
|
|
53
|
+
test('should have the class of .chart--no-scale added as there is less than 5 bars', () => {
|
|
54
|
+
let component = document.querySelector('iam-barchart');
|
|
55
|
+
expect(component.classList).toContain("chart--no-scale");
|
|
56
|
+
});
|
|
57
|
+
});
|
|
@@ -100,8 +100,8 @@ $chart-height-lg: #{rem(200)}!default;
|
|
|
100
100
|
|
|
101
101
|
display: flex;
|
|
102
102
|
flex-direction: column;
|
|
103
|
-
|
|
104
|
-
font-weight: var(--chart-font-weight, bold)
|
|
103
|
+
position: relative;
|
|
104
|
+
font-weight: var(--chart-font-weight, bold);
|
|
105
105
|
color: var(--chart-text-color, black);
|
|
106
106
|
|
|
107
107
|
|
|
@@ -210,7 +210,6 @@ $chart-height-lg: #{rem(200)}!default;
|
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
.key {
|
|
213
|
-
|
|
214
213
|
margin: 0;
|
|
215
214
|
|
|
216
215
|
&:before {
|
|
@@ -234,6 +233,16 @@ $chart-height-lg: #{rem(200)}!default;
|
|
|
234
233
|
}
|
|
235
234
|
}
|
|
236
235
|
|
|
236
|
+
@for $i from 1 to 10 {
|
|
237
|
+
|
|
238
|
+
.chart__outer input[type="checkbox"]:focus:nth-child(#{$i}) ~ .chart__key .key:nth-child(#{$i}) {
|
|
239
|
+
background: var(--colour-btn-action-hover-bg)!important;
|
|
240
|
+
border: var(--btn-border-width) solid var(--colour-muted)!important;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
237
246
|
// Hide chart keys
|
|
238
247
|
.chart__outer > input[type="checkbox"]:not(:checked) ~ .chart__key .key {
|
|
239
248
|
|
|
@@ -418,7 +427,7 @@ $chart-height-lg: #{rem(200)}!default;
|
|
|
418
427
|
tbody tr {
|
|
419
428
|
display: flex;
|
|
420
429
|
flex-direction: row;
|
|
421
|
-
justify-content: var(--chart-bar-alignment
|
|
430
|
+
justify-content: var(--chart-bar-alignment, left);
|
|
422
431
|
align-items: flex-end;
|
|
423
432
|
border: none;
|
|
424
433
|
width: 100%;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
export const trackComponentRegistered = (componentName: string) => {
|
|
3
|
+
// Data layer Web component created
|
|
4
|
+
window.dataLayer = window.dataLayer || [];
|
|
5
|
+
window.dataLayer.push({
|
|
6
|
+
"event": "customElementRegistered",
|
|
7
|
+
"element": componentName
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const trackComponent = (component:any, componentName:string, trackEvents:any) => {
|
|
12
|
+
|
|
13
|
+
// Data layer Web component created
|
|
14
|
+
window.dataLayer = window.dataLayer || [];
|
|
15
|
+
window.dataLayer.push({
|
|
16
|
+
"event": "customElementAdded",
|
|
17
|
+
"element": componentName
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
trackEvents.forEach((eventName:string) => {
|
|
21
|
+
component.addEventListener(eventName, function(event:any){
|
|
22
|
+
|
|
23
|
+
let eventDetails = {
|
|
24
|
+
"event": eventName,
|
|
25
|
+
"element": componentName,
|
|
26
|
+
"target": event.target
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
Object.keys(event.detail).forEach((eventKey:string) => {
|
|
30
|
+
|
|
31
|
+
const eventDetail = event.detail[eventKey];
|
|
32
|
+
eventDetails[eventKey] = eventDetail;
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
window.dataLayer.push(eventDetails);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
return true;
|
|
40
|
+
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
import {addClasses,setupChart,setEventListener,setEventObservers,setLongestLabel,setLongestValue,createTooltips} from "../../modules/chart.module";
|
|
3
|
+
import {trackComponent, trackComponentRegistered} from "../_global";
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
// TODO: tooltip
|
|
6
|
-
// TODO: responsive 'fit-content' classes done through JS
|
|
5
|
+
trackComponentRegistered("iam-barchart");
|
|
7
6
|
|
|
8
7
|
class iamBarChart extends HTMLElement {
|
|
9
8
|
|
|
@@ -36,34 +35,24 @@ class iamBarChart extends HTMLElement {
|
|
|
36
35
|
connectedCallback() {
|
|
37
36
|
|
|
38
37
|
const chartComponent = this;
|
|
39
|
-
|
|
40
38
|
const chartID = `chart-${Date.now()+(Math.floor(Math.random() * 100) + 1)}`;
|
|
41
|
-
|
|
42
39
|
const orginalTable = this.querySelector('table');
|
|
43
40
|
const clonedTable = orginalTable.cloneNode(true);
|
|
44
|
-
|
|
45
|
-
|
|
46
41
|
const chart = this.shadowRoot.querySelector('.chart');
|
|
47
42
|
const chartOuter = this.shadowRoot.querySelector('.chart__outer');
|
|
48
|
-
|
|
43
|
+
const barCount = chart.querySelectorAll('td:not(:first-child)').length;
|
|
49
44
|
|
|
50
45
|
chart.appendChild(clonedTable);
|
|
51
|
-
|
|
52
46
|
addClasses(chartComponent, chartOuter);
|
|
53
47
|
|
|
54
|
-
|
|
55
|
-
const barCount = chart.querySelectorAll('td:not(:first-child)').length;
|
|
56
|
-
|
|
57
|
-
if(barCount < 10){
|
|
48
|
+
if(barCount <= 10){
|
|
58
49
|
|
|
59
50
|
chartComponent.classList.add('chart--fit-content');
|
|
60
|
-
//chartComponent.classList.add('chart--display-data');
|
|
61
51
|
}
|
|
62
52
|
|
|
63
|
-
if(barCount
|
|
53
|
+
if(barCount <= 5){
|
|
64
54
|
|
|
65
55
|
chartComponent.classList.add('chart--no-scale');
|
|
66
|
-
//chartComponent.classList.add('chart--display-data');
|
|
67
56
|
}
|
|
68
57
|
|
|
69
58
|
setupChart(chartComponent,chartOuter,clonedTable);
|
|
@@ -71,8 +60,9 @@ class iamBarChart extends HTMLElement {
|
|
|
71
60
|
setEventListener(chartComponent,chartOuter);
|
|
72
61
|
setLongestLabel(chartOuter);
|
|
73
62
|
setLongestValue(chartOuter);
|
|
74
|
-
|
|
75
63
|
createTooltips(chartOuter);
|
|
64
|
+
|
|
65
|
+
trackComponent(chartComponent,"iam-barchart",['view-change']);
|
|
76
66
|
}
|
|
77
67
|
|
|
78
68
|
attributeChangedCallback(attrName, oldVal, newVal) {
|
|
@@ -46,7 +46,7 @@ class iamCard extends HTMLElement {
|
|
|
46
46
|
const createCardConent () {
|
|
47
47
|
|
|
48
48
|
// TODO split this out a bit
|
|
49
|
-
return `${this.hasAttribute('data-image') || this.hasAttribute('data-record') ? `<div class="card__head">${this.hasAttribute('data-image') ? `<img src="${this.getAttribute('data-image')}" alt="" loading="lazy" />` : ``} <div class="card__badges"><slot name="badges"></slot></div></div>` : ''}
|
|
49
|
+
return `${this.hasAttribute('data-image') || this.hasAttribute('data-record') ? `<div class="card__head" part="head">${this.hasAttribute('data-image') ? `<img src="${this.getAttribute('data-image')}" alt="" loading="lazy" />` : ``} <div class="card__badges"><slot name="badges"></slot></div></div>` : ''}
|
|
50
50
|
<div class="card__body" part="body">
|
|
51
51
|
${!this.hasAttribute('data-image') && this.querySelector('[slot="badges"]') && this.querySelector('[slot="checkbox"]') ? `<div class="card__badges card__badges--inline"><slot name="badges"></slot></div>` : ''}
|
|
52
52
|
${!this.hasAttribute('data-image') && !this.hasAttribute('data-record') && this.querySelector('[slot="badges"]') ? `<div class="card__badges"><slot name="badges"></slot></div>` : ''}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { numberOfDays } from './helpers'
|
|
2
1
|
|
|
3
2
|
// #region Functions that setup and trigger other functions
|
|
4
3
|
|
|
@@ -41,20 +40,18 @@ export const setupChart = (chartElement:any,chartOuter:any,tableElement:any) =>
|
|
|
41
40
|
Array.from(chartOuter.querySelectorAll(':scope > input[type="checkbox"],:scope > input[type="radio"]')).map((element: any) => { element.remove(); })
|
|
42
41
|
// #endregion
|
|
43
42
|
|
|
44
|
-
let {xaxis} = getChartData(chartElement
|
|
43
|
+
let {xaxis} = getChartData(chartElement);
|
|
45
44
|
|
|
46
|
-
setCellData(chartElement,
|
|
45
|
+
setCellData(chartElement,tableElement);
|
|
47
46
|
|
|
48
47
|
createChartKey(chartOuter,tableElement,chartKey);
|
|
49
|
-
createChartGuidelines(chartElement,
|
|
50
|
-
createChartYaxis(chartElement,
|
|
48
|
+
createChartGuidelines(chartElement,chartGuidelines);
|
|
49
|
+
createChartYaxis(chartElement,chartYaxis);
|
|
51
50
|
|
|
52
51
|
if(xaxis){
|
|
53
|
-
createXaxis(
|
|
52
|
+
createXaxis(chartOuter);
|
|
54
53
|
}
|
|
55
54
|
|
|
56
|
-
|
|
57
|
-
|
|
58
55
|
return true;
|
|
59
56
|
};
|
|
60
57
|
// #endregion
|
|
@@ -115,7 +112,7 @@ export const setEventListener = function(chartElement:any, chartOuter:any) {
|
|
|
115
112
|
|
|
116
113
|
|
|
117
114
|
shadowTable.innerHTML = table.innerHTML;
|
|
118
|
-
setCellData(chartElement,
|
|
115
|
+
setCellData(chartElement,shadowTable);
|
|
119
116
|
|
|
120
117
|
});
|
|
121
118
|
}
|
|
@@ -132,7 +129,7 @@ export const setEventObservers = function(chartElement:any,chartOuter:any) {
|
|
|
132
129
|
|
|
133
130
|
for (const mutation of mutationList) {
|
|
134
131
|
|
|
135
|
-
if(mutation.attributeName == 'class' || (mutation.type === 'attributes'
|
|
132
|
+
if(mutation.attributeName == 'class' || (mutation.type === 'attributes') || mutation.type === 'attributes') {
|
|
136
133
|
|
|
137
134
|
shadowTable.innerHTML = table.innerHTML;
|
|
138
135
|
setupChart(chartElement,chartOuter,shadowTable);
|
|
@@ -173,29 +170,29 @@ export const setEventObservers = function(chartElement:any,chartOuter:any) {
|
|
|
173
170
|
// #endregion
|
|
174
171
|
|
|
175
172
|
// #region GET functions
|
|
176
|
-
export const getChartData = function(chartElement:any
|
|
173
|
+
export const getChartData = function(chartElement:any){
|
|
177
174
|
|
|
178
175
|
|
|
179
|
-
let table =
|
|
176
|
+
let table = chartElement.shadowRoot.querySelector('.chart__wrapper table');
|
|
180
177
|
|
|
181
178
|
let min:any = chartElement.hasAttribute('data-min') ? chartElement.getAttribute('data-min') : 0;
|
|
182
179
|
let max:any = chartElement.hasAttribute('data-max') ? chartElement.getAttribute('data-max') : getLargestValue(chartElement,table);
|
|
183
|
-
let type:string = chartElement.hasAttribute('data-type') ? chartElement.getAttribute('data-type') : 'column';
|
|
180
|
+
//let type:string = chartElement.hasAttribute('data-type') ? chartElement.getAttribute('data-type') : 'column';
|
|
184
181
|
let yaxis:any = chartElement.hasAttribute('data-yaxis') ? chartElement.getAttribute('data-yaxis').split(',') : [];
|
|
185
182
|
let guidelines:any = chartElement.hasAttribute('data-guidelines') ? chartElement.getAttribute('data-guidelines').split(',') : [];
|
|
186
|
-
let targets:any = chartElement.hasAttribute('data-targets') ? JSON.parse(chartElement.getAttribute('data-targets')) : null;
|
|
187
|
-
let events:any = chartElement.hasAttribute('data-events') ? JSON.parse(chartElement.getAttribute('data-events')) : null;
|
|
183
|
+
//let targets:any = chartElement.hasAttribute('data-targets') ? JSON.parse(chartElement.getAttribute('data-targets')) : null;
|
|
184
|
+
//let events:any = chartElement.hasAttribute('data-events') ? JSON.parse(chartElement.getAttribute('data-events')) : null;
|
|
188
185
|
let xaxis:any = chartElement.hasAttribute('data-xaxis') ? chartElement.getAttribute('data-xaxis').split(',') : null;
|
|
189
|
-
let increment = chartElement.hasAttribute('data-increment') ? chartElement.getAttribute('data-increment'): null;
|
|
186
|
+
//let increment = chartElement.hasAttribute('data-increment') ? chartElement.getAttribute('data-increment'): null;
|
|
190
187
|
|
|
191
|
-
let start:any = chartElement.hasAttribute('data-start') ? chartElement.getAttribute('data-start') : 0;
|
|
192
|
-
let end:any = chartElement.hasAttribute('data-end') ? chartElement.getAttribute('data-end') : getLargestValue(chartElement,table); // TODO - get largest value from the data-xaxis
|
|
188
|
+
//let start:any = chartElement.hasAttribute('data-start') ? chartElement.getAttribute('data-start') : 0;
|
|
189
|
+
//let end:any = chartElement.hasAttribute('data-end') ? chartElement.getAttribute('data-end') : getLargestValue(chartElement,table); // TODO - get largest value from the data-xaxis
|
|
193
190
|
|
|
194
191
|
|
|
195
|
-
let slope:any = chartElement.hasAttribute('data-slope') ? chartElement.getAttribute('data-slope') : null;
|
|
196
|
-
let yInt:any = chartElement.hasAttribute('data-yint') ? chartElement.getAttribute('data-yint') : null;
|
|
192
|
+
//let slope:any = chartElement.hasAttribute('data-slope') ? chartElement.getAttribute('data-slope') : null;
|
|
193
|
+
//let yInt:any = chartElement.hasAttribute('data-yint') ? chartElement.getAttribute('data-yint') : null;
|
|
197
194
|
|
|
198
|
-
return {min,max,
|
|
195
|
+
return {min,max,yaxis,xaxis,guidelines};
|
|
199
196
|
}
|
|
200
197
|
|
|
201
198
|
function getLargestValue(chartElement:any,table:any){
|
|
@@ -252,7 +249,7 @@ const getValues = function(value:number,min:any,max:any,start?:number){
|
|
|
252
249
|
// #endregion
|
|
253
250
|
|
|
254
251
|
// #region SET functions - set data attributes and classes
|
|
255
|
-
export const setCellData = function(chartElement:any,
|
|
252
|
+
export const setCellData = function(chartElement:any,table:any){
|
|
256
253
|
|
|
257
254
|
Array.from(table.querySelectorAll('tbody tr')).forEach((tr:any) => {
|
|
258
255
|
|
|
@@ -274,7 +271,7 @@ export const setCellData = function(chartElement:any,chartOuter:any,table:any){
|
|
|
274
271
|
tr.setAttribute('data-numeric',rowValue);
|
|
275
272
|
});
|
|
276
273
|
|
|
277
|
-
let {min, max} = getChartData(chartElement
|
|
274
|
+
let {min, max} = getChartData(chartElement);
|
|
278
275
|
|
|
279
276
|
Array.from(table.querySelectorAll('tbody tr')).forEach((tr:any, index) => {
|
|
280
277
|
|
|
@@ -299,19 +296,6 @@ export const setCellData = function(chartElement:any,chartOuter:any,table:any){
|
|
|
299
296
|
td.setAttribute('data-label',table.querySelectorAll('thead th')[index].textContent);
|
|
300
297
|
});
|
|
301
298
|
|
|
302
|
-
/*
|
|
303
|
-
if(tr.querySelector('[data-label="Total"]')){
|
|
304
|
-
tr.setAttribute('data-total',tr.querySelector('[data-label="Total"][data-numeric]').getAttribute('data-numeric'));
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
if(tr.querySelector('[data-label="Min"]')){
|
|
308
|
-
tr.setAttribute('data-min',tr.querySelector('[data-label="Min"][data-numeric]').getAttribute('data-numeric'));
|
|
309
|
-
}
|
|
310
|
-
if(tr.querySelector('[data-label="Max"]')){
|
|
311
|
-
tr.setAttribute('data-max',tr.querySelector('[data-label="Max"][data-numeric]').getAttribute('data-numeric'));
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
*/
|
|
315
299
|
|
|
316
300
|
let rowMin = tr.hasAttribute('data-min') ? tr.getAttribute('data-min') : min;
|
|
317
301
|
let rowMax = tr.hasAttribute('data-max') ? tr.getAttribute('data-max') : max;
|
|
@@ -437,20 +421,13 @@ function createChartKeyItem(chartID:string,index:number,text:Array<string>,chart
|
|
|
437
421
|
return previousInput;
|
|
438
422
|
}
|
|
439
423
|
|
|
440
|
-
export const createChartGuidelines = function(chartElement:any,
|
|
424
|
+
export const createChartGuidelines = function(chartElement:any,chartGuidelines:any){
|
|
441
425
|
|
|
442
|
-
let {min, max, yaxis,
|
|
426
|
+
let {min, max, yaxis, guidelines} = getChartData(chartElement);
|
|
443
427
|
|
|
444
428
|
if(!guidelines.length)
|
|
445
429
|
guidelines = yaxis;
|
|
446
430
|
|
|
447
|
-
|
|
448
|
-
if(increment == "days"){
|
|
449
|
-
|
|
450
|
-
max = numberOfDays(min,max);
|
|
451
|
-
min = 0;
|
|
452
|
-
}
|
|
453
|
-
|
|
454
431
|
chartGuidelines.innerHTML = '';
|
|
455
432
|
for (var i = 0; i < guidelines.length; i++) {
|
|
456
433
|
|
|
@@ -463,56 +440,30 @@ export const createChartGuidelines = function(chartElement:any,chartOuter:any,ch
|
|
|
463
440
|
}
|
|
464
441
|
}
|
|
465
442
|
|
|
466
|
-
export const createChartYaxis = function(chartElement:any,
|
|
467
|
-
|
|
468
|
-
let {min, max, yaxis, increment} = getChartData(chartElement,chartOuter);
|
|
469
|
-
|
|
470
|
-
let startDay = min;
|
|
471
|
-
|
|
472
|
-
if(increment == "days"){
|
|
473
|
-
|
|
474
|
-
max = numberOfDays(min,max);
|
|
475
|
-
min = 0;
|
|
476
|
-
}
|
|
443
|
+
export const createChartYaxis = function(chartElement:any,chartYaxis:any){
|
|
477
444
|
|
|
445
|
+
let {min, max, yaxis} = getChartData(chartElement);
|
|
478
446
|
|
|
479
447
|
chartYaxis.innerHTML = '';
|
|
480
448
|
for (var i = 0; i < yaxis.length; i++) {
|
|
481
449
|
|
|
482
450
|
let value = parseFloat(yaxis[i].replace('£','').replace('%',''));
|
|
483
451
|
|
|
484
|
-
if(increment == "days"){
|
|
485
|
-
|
|
486
|
-
value = numberOfDays(startDay,yaxis[i]);
|
|
487
|
-
|
|
488
|
-
}
|
|
489
|
-
|
|
490
452
|
let { axis } = getValues(value,min,max);
|
|
491
453
|
chartYaxis.innerHTML += `<div class="axis__point" style="--percent:${axis}%;"><span>${yaxis[i]}</span></div>`;
|
|
492
454
|
}
|
|
493
455
|
}
|
|
494
456
|
|
|
495
|
-
export const createXaxis = function(
|
|
457
|
+
export const createXaxis = function(chartOuter:any){
|
|
496
458
|
|
|
497
459
|
const chart = chartOuter.querySelector('.chart');
|
|
498
460
|
let chartXaxis = chartOuter.querySelector('.chart__xaxis');
|
|
499
461
|
|
|
500
|
-
let {increment,start,end} = getChartData(chartElement,chartOuter);
|
|
501
|
-
|
|
502
462
|
if(!chartXaxis){
|
|
503
463
|
chartXaxis = document.createElement('div');
|
|
504
464
|
chartXaxis.setAttribute('class','chart__xaxis');
|
|
505
465
|
}
|
|
506
|
-
if(increment && start && end){
|
|
507
|
-
chartXaxis.innerHTML = '';
|
|
508
|
-
for (var i = 0; i < xaxis.length; i++) {
|
|
509
466
|
|
|
510
|
-
let value = parseFloat(xaxis[i].replace('£','').replace('%',''));
|
|
511
|
-
let position = ((value - start)/(end - start)) * 100;
|
|
512
|
-
|
|
513
|
-
chartXaxis.innerHTML += `<div class="axis__point" style="--percent:${position}%;"><span>${xaxis[i]}</span></div>`;
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
467
|
chart.prepend(chartXaxis);
|
|
517
468
|
}
|
|
518
469
|
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import '@testing-library/jest-dom'
|
|
3
|
+
import {getChartData} from "../modules/chart.module";
|
|
4
|
+
import puppeteer from 'puppeteer';
|
|
5
|
+
import "expect-puppeteer";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
import iamBarChart from "../components/barchart/barchart.component";
|
|
9
|
+
|
|
10
|
+
describe('The bar chart component', () => {
|
|
11
|
+
|
|
12
|
+
if (!window.customElements.get(`iam-barchart`))
|
|
13
|
+
window.customElements.define(`iam-barchart`, iamBarChart);
|
|
14
|
+
|
|
15
|
+
document.body.innerHTML = `
|
|
16
|
+
<iam-barchart>
|
|
17
|
+
<table>
|
|
18
|
+
<thead>
|
|
19
|
+
<tr>
|
|
20
|
+
<th>Items</th>
|
|
21
|
+
<th>Value</th>
|
|
22
|
+
</tr>
|
|
23
|
+
</thead>
|
|
24
|
+
<tbody>
|
|
25
|
+
<tr>
|
|
26
|
+
<td>Item 1</td>
|
|
27
|
+
<td>300</td>
|
|
28
|
+
</tr>
|
|
29
|
+
<tr>
|
|
30
|
+
<td>Item 2</td>
|
|
31
|
+
<td>150</td>
|
|
32
|
+
</tr>
|
|
33
|
+
<tr>
|
|
34
|
+
<td>Item 3</td>
|
|
35
|
+
<td>100</td>
|
|
36
|
+
</tr>
|
|
37
|
+
</tbody>
|
|
38
|
+
</table>
|
|
39
|
+
</iam-barchart>`;
|
|
40
|
+
|
|
41
|
+
test('should create the min attribute as 0', () => {
|
|
42
|
+
|
|
43
|
+
let component = document.querySelector('iam-barchart');
|
|
44
|
+
let {min} = getChartData(component);
|
|
45
|
+
|
|
46
|
+
expect(min).toEqual(0);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('should equal the largest single value', () => {
|
|
50
|
+
|
|
51
|
+
let component = document.querySelector('iam-barchart');
|
|
52
|
+
let {max} = getChartData(component);
|
|
53
|
+
|
|
54
|
+
expect(max).toEqual(300);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('should equal the largest single value', () => {
|
|
58
|
+
|
|
59
|
+
let component = document.querySelector('iam-barchart');
|
|
60
|
+
let {max} = getChartData(component);
|
|
61
|
+
|
|
62
|
+
expect(max).toEqual(300);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test('should have the class of .chart--fit-content added as there is less than 10 bars', () => {
|
|
66
|
+
|
|
67
|
+
let component = document.querySelector('iam-barchart');
|
|
68
|
+
expect(component.classList).toContain("chart--fit-content");
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
test('should have the class of .chart--no-scale added as there is less than 5 bars', () => {
|
|
72
|
+
|
|
73
|
+
let component = document.querySelector('iam-barchart');
|
|
74
|
+
expect(component.classList).toContain("chart--no-scale");
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
});
|
package/dist/components.es.js
CHANGED
|
@@ -67,7 +67,7 @@ const Ra = /* @__PURE__ */ m(U, [["render", G]]), J = (t) => t.charAt(0).toUpper
|
|
|
67
67
|
},
|
|
68
68
|
created() {
|
|
69
69
|
this.$nextTick(function() {
|
|
70
|
-
import("./table.component.min-
|
|
70
|
+
import("./table.component.min-e37ebd8f.mjs").then((t) => {
|
|
71
71
|
window.customElements.get("iam-table") || window.customElements.define("iam-table", t.default);
|
|
72
72
|
}).catch((t) => {
|
|
73
73
|
console.log(t.message);
|
|
@@ -453,7 +453,7 @@ const N = /* @__PURE__ */ m(ne, [["render", Se]]), xe = {
|
|
|
453
453
|
},
|
|
454
454
|
created() {
|
|
455
455
|
this.$nextTick(function() {
|
|
456
|
-
import("./fileupload.component.min-
|
|
456
|
+
import("./fileupload.component.min-1428f816.mjs").then((t) => {
|
|
457
457
|
window.customElements.get("iam-fileupload") || window.customElements.define("iam-fileupload", t.default);
|
|
458
458
|
}).catch((t) => {
|
|
459
459
|
console.log(t.message);
|
|
@@ -483,7 +483,7 @@ const qe = {
|
|
|
483
483
|
props: {},
|
|
484
484
|
mounted() {
|
|
485
485
|
this.$nextTick(function() {
|
|
486
|
-
import("./accordion.component.min-
|
|
486
|
+
import("./accordion.component.min-62ce9a03.mjs").then((t) => {
|
|
487
487
|
window.customElements.get("iam-accordion") || window.customElements.define("iam-accordion", t.default);
|
|
488
488
|
}).catch((t) => {
|
|
489
489
|
console.log(t.message);
|
|
@@ -592,7 +592,7 @@ const Va = /* @__PURE__ */ m(Ne, [["render", Fe]]), ze = {
|
|
|
592
592
|
name: "Card",
|
|
593
593
|
created() {
|
|
594
594
|
this.$nextTick(function() {
|
|
595
|
-
import("./card.component.min-
|
|
595
|
+
import("./card.component.min-c7fcb932.mjs").then((t) => {
|
|
596
596
|
window.customElements.get("iam-card") || window.customElements.define("iam-card", t.default);
|
|
597
597
|
}).catch((t) => {
|
|
598
598
|
console.log(t.message);
|
|
@@ -623,7 +623,7 @@ const Fa = /* @__PURE__ */ m(ze, [["render", Be]]), Oe = {
|
|
|
623
623
|
},
|
|
624
624
|
mounted() {
|
|
625
625
|
this.$nextTick(function() {
|
|
626
|
-
import("./carousel.component.min-
|
|
626
|
+
import("./carousel.component.min-561f6fb9.mjs").then((t) => {
|
|
627
627
|
window.customElements.get("iam-carousel") || window.customElements.define("iam-carousel", t.default);
|
|
628
628
|
}).catch((t) => {
|
|
629
629
|
console.log(t.message);
|
|
@@ -652,7 +652,7 @@ const za = /* @__PURE__ */ m(Oe, [["render", We]]), Ke = {
|
|
|
652
652
|
},
|
|
653
653
|
mounted() {
|
|
654
654
|
this.$nextTick(function() {
|
|
655
|
-
import("./header.component.min-
|
|
655
|
+
import("./header.component.min-98618cb0.mjs").then((t) => {
|
|
656
656
|
window.customElements.get("iam-header") || window.customElements.define("iam-header", t.default);
|
|
657
657
|
}).catch((t) => {
|
|
658
658
|
console.log(t.message);
|
|
@@ -1048,7 +1048,7 @@ const Wa = /* @__PURE__ */ m(_t, [["render", Ht]]), Mt = {
|
|
|
1048
1048
|
name: "Nav",
|
|
1049
1049
|
mounted() {
|
|
1050
1050
|
this.$nextTick(function() {
|
|
1051
|
-
import("./nav.component.min-
|
|
1051
|
+
import("./nav.component.min-78e6bbef.mjs").then((t) => {
|
|
1052
1052
|
window.customElements.get("iam-nav") || window.customElements.define("iam-nav", t.default);
|
|
1053
1053
|
}).catch((t) => {
|
|
1054
1054
|
console.log(t.message);
|
|
@@ -1168,7 +1168,7 @@ const Zt = {
|
|
|
1168
1168
|
name: "Tabs",
|
|
1169
1169
|
created() {
|
|
1170
1170
|
this.$nextTick(function() {
|
|
1171
|
-
import("./tabs.component.min-
|
|
1171
|
+
import("./tabs.component.min-6a848435.mjs").then((t) => {
|
|
1172
1172
|
window.customElements.get("iam-tabs") || window.customElements.define("iam-tabs", t.default);
|
|
1173
1173
|
}).catch((t) => {
|
|
1174
1174
|
console.log(t.message);
|
|
@@ -1315,7 +1315,7 @@ function ha(t, a, e, i, r, s) {
|
|
|
1315
1315
|
}
|
|
1316
1316
|
const es = /* @__PURE__ */ m(pa, [["render", ha]]);
|
|
1317
1317
|
/*!
|
|
1318
|
-
* iamKey
|
|
1318
|
+
* iamKey v6.0.0
|
|
1319
1319
|
* Copyright 2022-2024 iamproperty
|
|
1320
1320
|
*/
|
|
1321
1321
|
function fa(t, a) {
|
|
@@ -1485,7 +1485,7 @@ const as = /* @__PURE__ */ m(ka, [["render", Aa]]), La = {
|
|
|
1485
1485
|
props: {},
|
|
1486
1486
|
mounted() {
|
|
1487
1487
|
this.$nextTick(function() {
|
|
1488
|
-
import("./actionbar.component.min-
|
|
1488
|
+
import("./actionbar.component.min-80250f38.mjs").then((t) => {
|
|
1489
1489
|
window.customElements.get("iam-actionbar") || window.customElements.define("iam-actionbar", t.default);
|
|
1490
1490
|
}).catch((t) => {
|
|
1491
1491
|
console.log(t.message);
|
|
@@ -1500,7 +1500,7 @@ function Sa(t, a, e, i, r, s) {
|
|
|
1500
1500
|
}
|
|
1501
1501
|
const ss = /* @__PURE__ */ m(La, [["render", Sa]]);
|
|
1502
1502
|
/*!
|
|
1503
|
-
* iamKey
|
|
1503
|
+
* iamKey v6.0.0
|
|
1504
1504
|
* Copyright 2022-2024 iamproperty
|
|
1505
1505
|
*/
|
|
1506
1506
|
class R extends HTMLElement {
|