fluency-v8-components 1.6.1 → 1.6.2
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/dist/fluency-v8-components.es.js +1 -1
- package/dist/fluency-v8-components.umd.js +151 -127
- package/dist/{index-BAGLjhJi.mjs → index-JUukMsbD.mjs} +10960 -10916
- package/dist/{index.es-DW6Ls8hH.mjs → index.es-BtbsMJYu.mjs} +1 -1
- package/dist/purify.es-CRlZ0Imf.mjs +553 -0
- package/package.json +1 -1
- package/src/assets/main.css +4 -4
- package/src/components/charts/AlertChart.vue +3 -3
- package/src/components/charts/BarChartHorizontal.vue +29 -9
- package/src/components/charts/LineChart.vue +4 -4
- package/src/components/charts/PieChart.vue +33 -6
- package/src/components/charts/StackedChart.vue +5 -3
- package/src/components/charts/StackedChartClustered.vue +8 -5
- package/src/fpl/Panel.vue +15 -14
- package/src/fpl/Panels/Counter.vue +5 -2
- package/src/fpl/Panels/PieChart.vue +2 -2
- package/src/utils/download.js +28 -17
- package/dist/purify.es-DHbHSKL1.mjs +0 -528
|
@@ -91,15 +91,27 @@ export default {
|
|
|
91
91
|
acc[i] = field ? field : "(no name)";
|
|
92
92
|
return acc;
|
|
93
93
|
}, {});
|
|
94
|
+
const valueMap = data.values.reduce((acc, value, i) => {
|
|
95
|
+
acc[i] = value || 0;
|
|
96
|
+
return acc;
|
|
97
|
+
}, {});
|
|
98
|
+
|
|
99
|
+
const formatValue = (value) => {
|
|
100
|
+
if (this.unit === "Bytes (B)" || this.unit === "B") {
|
|
101
|
+
return dataCount(value) + "B";
|
|
102
|
+
}
|
|
103
|
+
if (this.unit === "Cost ($)") {
|
|
104
|
+
return costCount(value);
|
|
105
|
+
}
|
|
106
|
+
if (this.unit === "Percent (%)") {
|
|
107
|
+
return value.toFixed(2) + "%";
|
|
108
|
+
}
|
|
109
|
+
return humanCount(value);
|
|
110
|
+
};
|
|
94
111
|
|
|
95
112
|
// Declare the tooltip mouseover functions
|
|
96
113
|
const mouseoverEmpty = (event, d) => {
|
|
97
|
-
const value =
|
|
98
|
-
this.unit === "Bytes (B)" || this.unit === "B"
|
|
99
|
-
? dataCount(d.values) + "B"
|
|
100
|
-
: this.unit === "Percent (%)"
|
|
101
|
-
? d.values.toFixed(2) + "%"
|
|
102
|
-
: humanCount(d.values);
|
|
114
|
+
const value = formatValue(d.values);
|
|
103
115
|
event.target.style.opacity = 0.4;
|
|
104
116
|
d3.select("#" + this.id + "tooltip")
|
|
105
117
|
.html(
|
|
@@ -163,7 +175,11 @@ export default {
|
|
|
163
175
|
.attr("y", (d, i) => y(i))
|
|
164
176
|
.attr("width", (d) => 0)
|
|
165
177
|
.attr("height", y.bandwidth())
|
|
166
|
-
.attr(
|
|
178
|
+
.attr(
|
|
179
|
+
"fill",
|
|
180
|
+
(d, i) =>
|
|
181
|
+
`${chartColors[i % chartColors.length]}${this.theme === "dark" ? "CC" : "99"}`
|
|
182
|
+
)
|
|
167
183
|
.style("opacity", 0.8);
|
|
168
184
|
// Animation
|
|
169
185
|
this.svg
|
|
@@ -185,7 +201,11 @@ export default {
|
|
|
185
201
|
.attr("y", (d, i) => y(i))
|
|
186
202
|
.attr("width", this.width - marginLeft)
|
|
187
203
|
.attr("height", y.bandwidth())
|
|
188
|
-
.attr(
|
|
204
|
+
.attr(
|
|
205
|
+
"fill",
|
|
206
|
+
(d, i) =>
|
|
207
|
+
`${chartColors[i % chartColors.length]}${this.theme === "dark" ? "CC" : "99"}`
|
|
208
|
+
)
|
|
189
209
|
.style("opacity", 0)
|
|
190
210
|
.on("mouseover", mouseoverEmpty)
|
|
191
211
|
.on("mouseout", mouseoutEmpty);
|
|
@@ -215,7 +235,7 @@ export default {
|
|
|
215
235
|
.axisRight(y)
|
|
216
236
|
.tickSize(0)
|
|
217
237
|
.tickFormat((d) => {
|
|
218
|
-
return domainMap[d]
|
|
238
|
+
return `${domainMap[d]} - ${formatValue(valueMap[d])}`;
|
|
219
239
|
})
|
|
220
240
|
)
|
|
221
241
|
.call((g) => g.select(".domain").remove())
|
|
@@ -286,7 +286,7 @@ export default {
|
|
|
286
286
|
.attr("stroke", (d) => {
|
|
287
287
|
return (
|
|
288
288
|
platformMetricsLabels[this.theme][d.action] ||
|
|
289
|
-
chartColors[d.index % chartColors.length]
|
|
289
|
+
`${chartColors[d.index % chartColors.length]}${this.theme === "dark" ? "CC" : "99"}`
|
|
290
290
|
);
|
|
291
291
|
})
|
|
292
292
|
.attr("stroke-width", 1.5)
|
|
@@ -330,7 +330,7 @@ export default {
|
|
|
330
330
|
"fill",
|
|
331
331
|
(d) =>
|
|
332
332
|
platformMetricsLabels[this.theme][series.action] ||
|
|
333
|
-
chartColors[d.index % chartColors.length]
|
|
333
|
+
`${chartColors[d.index % chartColors.length]}${this.theme === "dark" ? "CC" : "99"}`
|
|
334
334
|
)
|
|
335
335
|
.attr("r", 2.5)
|
|
336
336
|
.attr("cx", (d) => x(d.slots))
|
|
@@ -384,7 +384,7 @@ export default {
|
|
|
384
384
|
.style("fill", (d) => {
|
|
385
385
|
return (
|
|
386
386
|
platformMetricsLabels[this.theme][d.action] ||
|
|
387
|
-
chartColors[d.index % chartColors.length]
|
|
387
|
+
`${chartColors[d.index % chartColors.length]}${this.theme === "dark" ? "CC" : "99"}`
|
|
388
388
|
);
|
|
389
389
|
})
|
|
390
390
|
.on("mouseover", legendMouseover)
|
|
@@ -403,7 +403,7 @@ export default {
|
|
|
403
403
|
.style("fill", (d) => {
|
|
404
404
|
return (
|
|
405
405
|
platformMetricsLabels[this.theme][d.action] ||
|
|
406
|
-
chartColors[d.index % chartColors.length]
|
|
406
|
+
`${chartColors[d.index % chartColors.length]}${this.theme === "dark" ? "CC" : "99"}`
|
|
407
407
|
);
|
|
408
408
|
})
|
|
409
409
|
.text((d) => d.action || "(no name)")
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
3
|
-
<div :id="id
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
<div :
|
|
2
|
+
<div class="flex w-full flex-col items-center">
|
|
3
|
+
<div :id="id">
|
|
4
|
+
<div :id="id + 'tooltip'" role="tooltip" class="tooltip"></div>
|
|
5
|
+
</div>
|
|
6
|
+
<div class="overflow-auto" :style="`width: ${width}px; overflow: auto`">
|
|
7
|
+
<div :id="id + 'legend'"></div>
|
|
8
|
+
</div>
|
|
7
9
|
</div>
|
|
8
10
|
</template>
|
|
9
11
|
<script>
|
|
@@ -57,6 +59,11 @@ export default {
|
|
|
57
59
|
this.initializeChart();
|
|
58
60
|
this.createChart();
|
|
59
61
|
},
|
|
62
|
+
watch: {
|
|
63
|
+
theme() {
|
|
64
|
+
this.updateThemeStyles();
|
|
65
|
+
},
|
|
66
|
+
},
|
|
60
67
|
methods: {
|
|
61
68
|
initializeChart() {
|
|
62
69
|
this.svg = d3
|
|
@@ -214,7 +221,9 @@ export default {
|
|
|
214
221
|
return arc(d);
|
|
215
222
|
})
|
|
216
223
|
.attr("fill", (d, i) =>
|
|
217
|
-
!total
|
|
224
|
+
!total
|
|
225
|
+
? chartColors[0]
|
|
226
|
+
: `${chartColors[i % chartColors.length]}${handle.theme === "dark" ? "CC" : "99"}`
|
|
218
227
|
)
|
|
219
228
|
.style("opacity", 0.8)
|
|
220
229
|
.style("fill-opacity", 0)
|
|
@@ -288,6 +297,24 @@ export default {
|
|
|
288
297
|
exit.call((g) => g.style("opacity", 0).remove());
|
|
289
298
|
}
|
|
290
299
|
},
|
|
300
|
+
updateThemeStyles() {
|
|
301
|
+
if (!this.svg) {
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
const total = this.data.reduce((acc, d) => acc + (d.values || 0), 0);
|
|
305
|
+
const textColor = this.theme === "dark" ? "white" : "black";
|
|
306
|
+
this.svg
|
|
307
|
+
.selectAll("polyline." + this.id + "labels")
|
|
308
|
+
.style("stroke", textColor);
|
|
309
|
+
this.svg.selectAll("text." + this.id + "labels").style("fill", textColor);
|
|
310
|
+
this.svg
|
|
311
|
+
.selectAll("path." + this.id + "pie")
|
|
312
|
+
.attr("fill", (d, i) =>
|
|
313
|
+
!total
|
|
314
|
+
? chartColors[0]
|
|
315
|
+
: `${chartColors[i % chartColors.length]}${this.theme === "dark" ? "CC" : "99"}`
|
|
316
|
+
);
|
|
317
|
+
},
|
|
291
318
|
},
|
|
292
319
|
};
|
|
293
320
|
</script>
|
|
@@ -271,7 +271,7 @@ export default {
|
|
|
271
271
|
"fill",
|
|
272
272
|
(d) =>
|
|
273
273
|
costLabels[this.theme][d.key] ||
|
|
274
|
-
chartColors[namesIndex.indexOf(d.key) % chartColors.length]
|
|
274
|
+
`${chartColors[namesIndex.indexOf(d.key) % chartColors.length]}${this.theme === "dark" ? "CC" : "99"}`
|
|
275
275
|
)
|
|
276
276
|
.selectAll("rect")
|
|
277
277
|
.data((D) => D.map((d) => ((d.key = D.key), d)))
|
|
@@ -333,7 +333,8 @@ export default {
|
|
|
333
333
|
.attr(
|
|
334
334
|
"fill",
|
|
335
335
|
(d, i) =>
|
|
336
|
-
costLabels[this.theme][d.key] ||
|
|
336
|
+
costLabels[this.theme][d.key] ||
|
|
337
|
+
`${chartColors[i % chartColors.length]}${this.theme === "dark" ? "CC" : "99"}`
|
|
337
338
|
)
|
|
338
339
|
.on("mouseover", legendMouseover)
|
|
339
340
|
.on("mouseout", legendMouseout)
|
|
@@ -351,7 +352,8 @@ export default {
|
|
|
351
352
|
.attr(
|
|
352
353
|
"fill",
|
|
353
354
|
(d, i) =>
|
|
354
|
-
costLabels[this.theme][d.key] ||
|
|
355
|
+
costLabels[this.theme][d.key] ||
|
|
356
|
+
`${chartColors[i % chartColors.length]}${this.theme === "dark" ? "CC" : "99"}`
|
|
355
357
|
)
|
|
356
358
|
.text((d, i) => adjustText(this.names[d[0].key], 700))
|
|
357
359
|
.attr("font-weight", 500)
|
|
@@ -239,9 +239,12 @@ export default {
|
|
|
239
239
|
instancesIndex.length +
|
|
240
240
|
0.5
|
|
241
241
|
) ||
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
242
|
+
`${
|
|
243
|
+
chartColors[
|
|
244
|
+
namesIndex.indexOf(d.key.split(":")[0]) %
|
|
245
|
+
chartColors.length
|
|
246
|
+
]
|
|
247
|
+
}${this.theme === "dark" ? "CC" : "99"}`
|
|
245
248
|
)
|
|
246
249
|
.selectAll("rect")
|
|
247
250
|
.data((D) => D.map((d) => ((d.key = D.key), d)))
|
|
@@ -363,7 +366,7 @@ export default {
|
|
|
363
366
|
"fill",
|
|
364
367
|
(d, i) =>
|
|
365
368
|
platformMetricsLabels[this.theme][d] ||
|
|
366
|
-
chartColors[i % chartColors.length]
|
|
369
|
+
`${chartColors[i % chartColors.length]}${this.theme === "dark" ? "CC" : "99"}`
|
|
367
370
|
)
|
|
368
371
|
.on("mouseover", legendMouseover)
|
|
369
372
|
.on("mouseout", legendMouseout)
|
|
@@ -382,7 +385,7 @@ export default {
|
|
|
382
385
|
"fill",
|
|
383
386
|
(d, i) =>
|
|
384
387
|
platformMetricsLabels[this.theme][d] ||
|
|
385
|
-
chartColors[i % chartColors.length]
|
|
388
|
+
`${chartColors[i % chartColors.length]}${this.theme === "dark" ? "CC" : "99"}`
|
|
386
389
|
)
|
|
387
390
|
.text((d, i) => adjustText(d, 700))
|
|
388
391
|
.attr("font-weight", 500)
|
package/src/fpl/Panel.vue
CHANGED
|
@@ -72,20 +72,21 @@
|
|
|
72
72
|
<ActionButtons download hideTooltip @download="downloadTableCSV" />
|
|
73
73
|
</div>
|
|
74
74
|
</div>
|
|
75
|
-
<
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
75
|
+
<div v-if="!noData" class="flex w-full justify-center">
|
|
76
|
+
<component
|
|
77
|
+
:is="getComponent()"
|
|
78
|
+
:config="panel.panelConfig"
|
|
79
|
+
:obj="obj"
|
|
80
|
+
:id="`panel${panel.key}${isMobile ? '-mobile' : ''}`"
|
|
81
|
+
:layout="layout"
|
|
82
|
+
:class="
|
|
83
|
+
panel.panelType === 'image' || panel.panelType === 'text' ? '' : 'p-2'
|
|
84
|
+
"
|
|
85
|
+
:theme="theme"
|
|
86
|
+
:paginationStore="paginationStore"
|
|
87
|
+
:apiKey="apiKey"
|
|
88
|
+
/>
|
|
89
|
+
</div>
|
|
89
90
|
<span v-else class="flex justify-center pt-10 text-lg font-semibold">
|
|
90
91
|
No data available
|
|
91
92
|
</span>
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
2
|
+
<div
|
|
3
|
+
class="flex w-full items-center justify-center"
|
|
4
|
+
:style="`height: ${layout.h * 60 - 40}px`"
|
|
5
|
+
>
|
|
3
6
|
<span
|
|
4
7
|
:class="[
|
|
5
|
-
'
|
|
8
|
+
'overflow-hidden text-center',
|
|
6
9
|
layout.w > 4 ? 'text-7xl' : 'text-5xl',
|
|
7
10
|
]"
|
|
8
11
|
>
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div>
|
|
2
|
+
<div class="w-full overflow-hidden">
|
|
3
3
|
<PieChart
|
|
4
4
|
v-if="!redraw"
|
|
5
5
|
:data="data"
|
|
6
6
|
:id="id"
|
|
7
7
|
unit="Value"
|
|
8
8
|
:height="props.layout.h * 60 - 40"
|
|
9
|
-
:width="props.layout.w *
|
|
9
|
+
:width="props.layout.w * 78"
|
|
10
10
|
tooltipOffset="offset"
|
|
11
11
|
:value-name="props.config.categories.focus.name"
|
|
12
12
|
:theme="theme"
|
package/src/utils/download.js
CHANGED
|
@@ -64,8 +64,8 @@ const panelCSVDownload = (title, columns, rows) => {
|
|
|
64
64
|
const exportAsCsv = (table) => {
|
|
65
65
|
let csv =
|
|
66
66
|
table.columns
|
|
67
|
-
.map((col) => col.replaceAll(", ", " ").replaceAll(",", " "))
|
|
68
|
-
.join("
|
|
67
|
+
// .map((col) => col.replaceAll(", ", " ").replaceAll(",", " "))
|
|
68
|
+
.join("|") + "\n";
|
|
69
69
|
|
|
70
70
|
const order = {};
|
|
71
71
|
table.columns.forEach((col, index) => {
|
|
@@ -79,10 +79,10 @@ const exportAsCsv = (table) => {
|
|
|
79
79
|
val = "";
|
|
80
80
|
}
|
|
81
81
|
if (typeof val === "string") {
|
|
82
|
-
val = val.replaceAll(", ", " ").replaceAll(",", " ");
|
|
82
|
+
// val = val.replaceAll(", ", " ").replaceAll(",", " ");
|
|
83
83
|
}
|
|
84
84
|
// add double quotes to csv export
|
|
85
|
-
r += '"' + val + '"' + "
|
|
85
|
+
r += '"' + val + '"' + "|";
|
|
86
86
|
});
|
|
87
87
|
csv += r.slice(0, -1) + "\n";
|
|
88
88
|
});
|
|
@@ -128,20 +128,31 @@ const reportToPdf = async (name, layouts) => {
|
|
|
128
128
|
const logoXOffset = 20;
|
|
129
129
|
const logoYOffset = 10;
|
|
130
130
|
const logo = await getLogo();
|
|
131
|
+
const clientLogo = await getClientLogo();
|
|
132
|
+
const poweredByText = "Powered by Fluency";
|
|
133
|
+
const poweredByTextWidth = pdf.getTextWidth(poweredByText);
|
|
131
134
|
|
|
132
135
|
let pageIndexOffset = 0;
|
|
133
136
|
let pageNumber = 1;
|
|
134
137
|
|
|
138
|
+
const addNewPageMeta = () => {
|
|
139
|
+
pdf.addImage(logo, "png", logoXOffset, logoYOffset, logoWidth, logoHeight);
|
|
140
|
+
if (clientLogo) {
|
|
141
|
+
pdf.addImage(clientLogo, "png", pageWidth - logoWidth - logoXOffset, logoYOffset, logoWidth, logoHeight);
|
|
142
|
+
}
|
|
143
|
+
pdf.text((pageWidth - poweredByTextWidth) / 2, pageHeight - 10, poweredByText);
|
|
144
|
+
pdf.text(pageWidth - 2 * xMargin, pageHeight - 10, `Page ${pageNumber}`);
|
|
145
|
+
};
|
|
146
|
+
|
|
135
147
|
const widthUnit = Math.floor((pageWidth - xMargin) / layoutColumns);
|
|
136
148
|
const heightUnit = widthUnit * 0.9;
|
|
137
149
|
pdf.setFontSize(fontSize);
|
|
138
150
|
pdf.setFont(undefined, "normal");
|
|
139
|
-
|
|
140
|
-
pdf.text(pageWidth - 2 * xMargin, pageHeight - 10, `Page ${pageNumber}`);
|
|
151
|
+
addNewPageMeta();
|
|
141
152
|
|
|
142
153
|
for (const layout of layouts.layout) {
|
|
143
154
|
const widget = document.getElementById(`grid-item-${layout.i}`);
|
|
144
|
-
const canvasOptions = {};
|
|
155
|
+
const canvasOptions = { scale: 4 };
|
|
145
156
|
const canvas = await html2canvas(widget, canvasOptions);
|
|
146
157
|
const img = canvas.toDataURL("image/png");
|
|
147
158
|
const x = layout.x * widthUnit;
|
|
@@ -151,15 +162,7 @@ const reportToPdf = async (name, layouts) => {
|
|
|
151
162
|
if (endOfImg > pageHeight + pageIndexOffset) {
|
|
152
163
|
pdf.addPage();
|
|
153
164
|
pageNumber += 1;
|
|
154
|
-
|
|
155
|
-
logo,
|
|
156
|
-
"png",
|
|
157
|
-
logoXOffset,
|
|
158
|
-
logoYOffset,
|
|
159
|
-
logoWidth,
|
|
160
|
-
logoHeight
|
|
161
|
-
);
|
|
162
|
-
pdf.text(pageWidth - 2 * xMargin, pageHeight - 10, `Page ${pageNumber}`);
|
|
165
|
+
addNewPageMeta();
|
|
163
166
|
pageIndexOffset = y;
|
|
164
167
|
}
|
|
165
168
|
// check if panel is oversized for page
|
|
@@ -187,10 +190,18 @@ const reportToPdf = async (name, layouts) => {
|
|
|
187
190
|
pdf.save(`${name}.pdf`);
|
|
188
191
|
};
|
|
189
192
|
|
|
190
|
-
const getLogo = () => {
|
|
193
|
+
const getLogo = async () => {
|
|
191
194
|
return document.getElementById("logo");
|
|
192
195
|
};
|
|
193
196
|
|
|
197
|
+
const getClientLogo = async () => {
|
|
198
|
+
const img = document.getElementById("client-logo");
|
|
199
|
+
if (img) {
|
|
200
|
+
return img;
|
|
201
|
+
}
|
|
202
|
+
return null;
|
|
203
|
+
};
|
|
204
|
+
|
|
194
205
|
const base64toImage = async (logo) => {
|
|
195
206
|
let data = {};
|
|
196
207
|
const img = new Image();
|