Skip to content

Commit f9075f8

Browse files
Fix linting errors
1 parent 361a86d commit f9075f8

1 file changed

Lines changed: 66 additions & 67 deletions

File tree

jQuery/src/index.js

Lines changed: 66 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -2,82 +2,81 @@ const registerGradient = DevExpress.common.charts.registerGradient;
22
const formatNumber = DevExpress.localization.formatNumber;
33

44
$(() => {
5-
let count = 0;
6-
$('#chart').dxChart({
7-
dataSource: chartData,
8-
title: 'Target vs Actual Spending 2024',
9-
series: [{
10-
type: 'bar',
11-
argumentField: 'month',
12-
valueField: 'targetSpend',
13-
name: 'Budget',
14-
color: "#5996ff"
15-
}, {
16-
type: 'spline',
17-
argumentField: 'month',
18-
valueField: 'actualSpend',
19-
name: 'Amount Spend',
20-
color: "#cb4bfa",
21-
}],
22-
valueAxis: [{
23-
constantLines: [{
24-
value: averageSpend,
25-
color: "#0000c7",
26-
label: {
27-
text: "Yearly Spend Average"
28-
},
29-
}]
30-
}],
31-
tooltip: {
32-
enabled: true,
33-
customizeTooltip: function(data) {
34-
const isValueAboveAverage = data.value > averageSpend;
35-
const aboveText = `${ formatNumber(data.value, "currency") }\n${ formatNumber(data.value - averageSpend, "currency") } above average spending.`;
36-
const belowText = `${ formatNumber(data.value, "currency") }\n${ formatNumber(averageSpend - data.value, "currency") } below average spending.`;
37-
return {text: isValueAboveAverage ? aboveText : belowText }
38-
}
5+
$('#chart').dxChart({
6+
dataSource: chartData,
7+
title: 'Target vs Actual Spending 2024',
8+
series: [{
9+
type: 'bar',
10+
argumentField: 'month',
11+
valueField: 'targetSpend',
12+
name: 'Budget',
13+
color: '#5996ff',
14+
}, {
15+
type: 'spline',
16+
argumentField: 'month',
17+
valueField: 'actualSpend',
18+
name: 'Amount Spend',
19+
color: '#cb4bfa',
20+
}],
21+
valueAxis: [{
22+
constantLines: [{
23+
value: averageSpend,
24+
color: '#0000c7',
25+
label: {
26+
text: 'Yearly Spend Average',
3927
},
40-
commonPaneSettings: {
41-
backgroundColor: {
42-
base: "#f5564a",
43-
fillId: registerGradient("linear", {
44-
colors: [{
45-
offset: "20%",
46-
color: "#dee4ff"
47-
}, {
48-
offset: "90%",
49-
color: "#ffdeff"
50-
}]
51-
})
52-
}
53-
},
54-
});
28+
}],
29+
}],
30+
tooltip: {
31+
enabled: true,
32+
customizeTooltip(data) {
33+
const isValueAboveAverage = data.value > averageSpend;
34+
const aboveText = `${formatNumber(data.value, 'currency')}\n${formatNumber(data.value - averageSpend, 'currency')} above average spending.`;
35+
const belowText = `${formatNumber(data.value, 'currency')}\n${formatNumber(averageSpend - data.value, 'currency')} below average spending.`;
36+
return { text: isValueAboveAverage ? aboveText : belowText };
37+
},
38+
},
39+
commonPaneSettings: {
40+
backgroundColor: {
41+
base: '#f5564a',
42+
fillId: registerGradient('linear', {
43+
colors: [{
44+
offset: '20%',
45+
color: '#dee4ff',
46+
}, {
47+
offset: '90%',
48+
color: '#ffdeff',
49+
}],
50+
}),
51+
},
52+
},
53+
});
5554
});
5655

5756
const chartData = [
58-
{ month: "January", targetSpend: 12000, actualSpend: 9500 },
59-
{ month: "February", targetSpend: 15500, actualSpend: 16500 },
60-
{ month: "March", targetSpend: 13500, actualSpend: 12000 },
61-
{ month: "April", targetSpend: 16000, actualSpend: 14000 },
62-
{ month: "May", targetSpend: 17000, actualSpend: 18500 },
63-
{ month: "June", targetSpend: 20000, actualSpend: 17500 },
64-
{ month: "July", targetSpend: 14500, actualSpend: 11000 },
65-
{ month: "August", targetSpend: 21000, actualSpend: 22500 },
66-
{ month: "September", targetSpend: 19000, actualSpend: 18000 },
67-
{ month: "October", targetSpend: 22000, actualSpend: 25000 },
68-
{ month: "November", targetSpend: 16000, actualSpend: 14500 },
69-
{ month: "December", targetSpend: 25000, actualSpend: 27000 },
57+
{ month: 'January', targetSpend: 12000, actualSpend: 9500 },
58+
{ month: 'February', targetSpend: 15500, actualSpend: 16500 },
59+
{ month: 'March', targetSpend: 13500, actualSpend: 12000 },
60+
{ month: 'April', targetSpend: 16000, actualSpend: 14000 },
61+
{ month: 'May', targetSpend: 17000, actualSpend: 18500 },
62+
{ month: 'June', targetSpend: 20000, actualSpend: 17500 },
63+
{ month: 'July', targetSpend: 14500, actualSpend: 11000 },
64+
{ month: 'August', targetSpend: 21000, actualSpend: 22500 },
65+
{ month: 'September', targetSpend: 19000, actualSpend: 18000 },
66+
{ month: 'October', targetSpend: 22000, actualSpend: 25000 },
67+
{ month: 'November', targetSpend: 16000, actualSpend: 14500 },
68+
{ month: 'December', targetSpend: 25000, actualSpend: 27000 },
7069
];
7170

7271
// A function cannot directly be assigned to the constantLines[].value property of Chart axes.
7372
const averageSpend = calculateAverageSpend();
7473

7574
function calculateAverageSpend() {
76-
let sum = 0;
75+
let sum = 0;
7776

78-
chartData.forEach(data => {
79-
sum += data.actualSpend;
80-
});
77+
chartData.forEach((data) => {
78+
sum += data.actualSpend;
79+
});
8180

82-
return sum / chartData.length;
83-
};
81+
return sum / chartData.length;
82+
}

0 commit comments

Comments
 (0)