fluency-v8-components 1.3.5 → 1.3.6
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 +99 -99
- package/dist/{index-q2NbjdVo.mjs → index-BBxccHNP.mjs} +7 -6
- package/dist/{index.es-PAPL4E6Y.mjs → index.es-D_XhLSeH.mjs} +1 -1
- package/package.json +3 -2
- package/src/assets/images/ai.svg +1 -0
- package/src/assets/images/github-dark.svg +1 -0
- package/src/assets/images/github.svg +1 -0
- package/src/assets/images/high-priority.svg +1 -0
- package/src/assets/images/power-off.svg +1 -0
- package/src/assets/images/save.svg +1 -0
- package/src/assets/index.ts +15 -0
- package/src/assets/main.css +505 -0
- package/src/assets/prism-theme.css +290 -0
- package/src/components/buttons/ActionButtons.vue +374 -0
- package/src/components/buttons/DropdownButton.vue +104 -0
- package/src/components/buttons/IconButton.vue +63 -0
- package/src/components/buttons/ImageButton.vue +16 -0
- package/src/components/buttons/MenuButton.vue +138 -0
- package/src/components/buttons/SubmitButtons.vue +51 -0
- package/src/components/buttons/TextButton.vue +40 -0
- package/src/components/charts/AlertChart.vue +376 -0
- package/src/components/charts/BarChart.vue +212 -0
- package/src/components/charts/BarChartHorizontal.vue +243 -0
- package/src/components/charts/CronChart.vue +146 -0
- package/src/components/charts/EmptyChart.vue +76 -0
- package/src/components/charts/GradientChart.vue +310 -0
- package/src/components/charts/LineChart.test.js +59 -0
- package/src/components/charts/LineChart.vue +434 -0
- package/src/components/charts/PieChart.vue +293 -0
- package/src/components/charts/ProgressChart.vue +106 -0
- package/src/components/charts/StackedChart.vue +364 -0
- package/src/components/charts/StackedChartClustered.vue +395 -0
- package/src/components/charts/TimelineChart.vue +215 -0
- package/src/components/charts/WorkflowChart.vue +520 -0
- package/src/components/common/AutoCompleteSearchBar.vue +100 -0
- package/src/components/common/AutoRefreshButton.vue +53 -0
- package/src/components/common/Breadcrumb.vue +45 -0
- package/src/components/common/ButtonToggle.vue +24 -0
- package/src/components/common/Card.vue +116 -0
- package/src/components/common/Carousel.vue +66 -0
- package/src/components/common/CategoryCard.vue +28 -0
- package/src/components/common/CodeEditor.vue +59 -0
- package/src/components/common/DatePicker.vue +21 -0
- package/src/components/common/DatePickerInput.vue +109 -0
- package/src/components/common/Dialog.vue +103 -0
- package/src/components/common/EditorHeading.vue +10 -0
- package/src/components/common/EventList.vue +41 -0
- package/src/components/common/Facet.vue +206 -0
- package/src/components/common/Feed.vue +58 -0
- package/src/components/common/Flag.vue +27 -0
- package/src/components/common/HomeCard.vue +20 -0
- package/src/components/common/ItemBox.vue +49 -0
- package/src/components/common/Loading.vue +19 -0
- package/src/components/common/LoadingDots.vue +12 -0
- package/src/components/common/PageHeading.vue +30 -0
- package/src/components/common/Pagination.vue +105 -0
- package/src/components/common/Popover.vue +24 -0
- package/src/components/common/PowerToggle.vue +130 -0
- package/src/components/common/ProgressBar.vue +33 -0
- package/src/components/common/RadioButtons.vue +52 -0
- package/src/components/common/Schedule.vue +79 -0
- package/src/components/common/SearchBar.vue +30 -0
- package/src/components/common/Separator.vue +3 -0
- package/src/components/common/Slideout.vue +95 -0
- package/src/components/common/Sort.vue +83 -0
- package/src/components/common/Table.vue +48 -0
- package/src/components/common/Tabs.vue +129 -0
- package/src/components/common/Tag.vue +53 -0
- package/src/components/common/Tooltip.vue +49 -0
- package/src/components/common/VerticalTabs.vue +34 -0
- package/src/components/common/card/CardItem.vue +27 -0
- package/src/components/common/card/CardItemGroup.vue +45 -0
- package/src/components/common/facet/Leaf.vue +97 -0
- package/src/components/common/facet/TriState.vue +37 -0
- package/src/components/common/table/TableData.vue +48 -0
- package/src/components/common/table/TableHeader.vue +21 -0
- package/src/components/dialogs/ChooseValueDialog.vue +97 -0
- package/src/components/dialogs/ConfirmDialog.vue +73 -0
- package/src/components/dialogs/CopyDialog.vue +51 -0
- package/src/components/dialogs/DownloadDialog.vue +48 -0
- package/src/components/dialogs/NameDescDialog.vue +74 -0
- package/src/components/dialogs/NameDialog.vue +56 -0
- package/src/components/dialogs/PopupEditor.vue +113 -0
- package/src/components/dialogs/ProgressDialog.vue +58 -0
- package/src/components/dialogs/ResetPasswordDialog.vue +58 -0
- package/src/components/dialogs/Wizard.vue +99 -0
- package/src/components/dialogs/wizard/Stepper.vue +31 -0
- package/src/components/form/CheckBox.vue +26 -0
- package/src/components/form/Editor.vue +93 -0
- package/src/components/form/FormCol.vue +19 -0
- package/src/components/form/FormRow.vue +19 -0
- package/src/components/form/FormSection.vue +21 -0
- package/src/components/form/GreyForm.vue +7 -0
- package/src/components/form/GreyInput.vue +51 -0
- package/src/components/form/GreyInputAutocomplete.vue +100 -0
- package/src/components/form/GreyInputCopy.vue +66 -0
- package/src/components/form/GreyInputGrow.vue +42 -0
- package/src/components/form/GreyInputToken.vue +78 -0
- package/src/components/form/GreyPassword.vue +36 -0
- package/src/components/form/GreySelect.vue +154 -0
- package/src/components/form/GreySelectInput.vue +123 -0
- package/src/components/form/GreySelectInputMultiple.vue +218 -0
- package/src/components/form/GreyTel.vue +58 -0
- package/src/components/form/HamburgerItem.vue +95 -0
- package/src/components/form/KeyValueEntry.vue +74 -0
- package/src/components/form/RadioInput.vue +38 -0
- package/src/components/form/UploadFile.vue +99 -0
- package/src/components/icons/AiIcon.vue +6 -0
- package/src/components/icons/GithubIcon.vue +18 -0
- package/src/components/icons/HighPriorityIcon.vue +6 -0
- package/src/components/icons/PowerOffIcon.vue +6 -0
- package/src/components/icons/SaveIcon.vue +6 -0
- package/src/components/index.js +134 -0
- package/src/components/menu/DialogMenu.vue +142 -0
- package/src/components/menu/GrandChild.vue +39 -0
- package/src/components/menu/GridMenu.vue +88 -0
- package/src/components/menu/MenuAvatar.vue +66 -0
- package/src/components/menu/MenuDesktop.vue +90 -0
- package/src/components/notifications/Notify.vue +123 -0
- package/src/components/notifications/NotifyList.vue +130 -0
- package/src/components/page-structure/FacetPage.vue +77 -0
- package/src/components/query/Child.vue +63 -0
- package/src/components/query/LVDBQuery.vue +38 -0
- package/src/components/status/Active.vue +44 -0
- package/src/components/status/ScoreLevel.vue +43 -0
- package/src/components/status/Status.vue +51 -0
- package/src/components/status/TaskDot.vue +25 -0
- package/src/components/status/TaskStatus.vue +26 -0
- package/src/components/status/TicketStatus.vue +201 -0
- package/src/components/status/Trend.vue +20 -0
- package/src/components/tables/ArgumentRunTable.vue +96 -0
- package/src/components/tables/ArgumentTable.vue +67 -0
- package/src/components/tables/CloudFormationParameters.vue +25 -0
- package/src/constants/colors.js +248 -0
- package/src/constants/font-map.js +128 -0
- package/src/constants/fpl2.js +162 -0
- package/src/constants/icon-svg.js +405 -0
- package/src/constants/schedule.js +52 -0
- package/src/fpl/AddPanel.vue +237 -0
- package/src/fpl/Configs/Alert.vue +16 -0
- package/src/fpl/Configs/AlertSprite.vue +2 -0
- package/src/fpl/Configs/Chart.vue +63 -0
- package/src/fpl/Configs/Config.js +154 -0
- package/src/fpl/Configs/Counter.vue +35 -0
- package/src/fpl/Configs/Histogram.vue +70 -0
- package/src/fpl/Configs/IPMap.vue +37 -0
- package/src/fpl/Configs/Image.vue +163 -0
- package/src/fpl/Configs/MetricChart.vue +20 -0
- package/src/fpl/Configs/PieChart.vue +37 -0
- package/src/fpl/Configs/SparkChart.vue +41 -0
- package/src/fpl/Configs/StackedBarChart.vue +49 -0
- package/src/fpl/Configs/Table.vue +211 -0
- package/src/fpl/Configs/Text.vue +14 -0
- package/src/fpl/Configs/TopNChart.vue +37 -0
- package/src/fpl/Outputs/FPLAlert.vue +64 -0
- package/src/fpl/Outputs/FPLStream.vue +41 -0
- package/src/fpl/Outputs/FPLTable.vue +77 -0
- package/src/fpl/Panel.vue +202 -0
- package/src/fpl/Panels/Alert.vue +85 -0
- package/src/fpl/Panels/AlertSprite.vue +9 -0
- package/src/fpl/Panels/Chart.vue +98 -0
- package/src/fpl/Panels/Counter.vue +43 -0
- package/src/fpl/Panels/Histogram.vue +138 -0
- package/src/fpl/Panels/IPMap.vue +48 -0
- package/src/fpl/Panels/Image.vue +35 -0
- package/src/fpl/Panels/MetricChart.vue +97 -0
- package/src/fpl/Panels/PieChart.vue +54 -0
- package/src/fpl/Panels/SparkChart.vue +166 -0
- package/src/fpl/Panels/StackedBarChart.vue +74 -0
- package/src/fpl/Panels/Table.vue +103 -0
- package/src/fpl/Panels/Text.vue +24 -0
- package/src/fpl/Panels/TopNChart.vue +69 -0
- package/src/fpl/index.js +39 -0
- package/src/utils/download.js +220 -0
- package/src/utils/formatOutput.js +156 -0
- package/src/utils/random.js +32 -0
- package/src/utils/timeUtils.js +138 -0
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :id="id" class="float-left">
|
|
3
|
+
<div :id="id + 'tooltip'" role="tooltip" class="tooltip"></div>
|
|
4
|
+
</div>
|
|
5
|
+
<div class="overflow-auto" :style="`height: ${height}px; overflow: auto`">
|
|
6
|
+
<div :id="id + 'legend'"></div>
|
|
7
|
+
</div>
|
|
8
|
+
</template>
|
|
9
|
+
<script>
|
|
10
|
+
import * as d3 from "d3";
|
|
11
|
+
import { alertChartColors, chartColors } from "@/constants/colors";
|
|
12
|
+
import { humanCount, dataCount } from "@/utils/formatOutput";
|
|
13
|
+
|
|
14
|
+
export default {
|
|
15
|
+
props: {
|
|
16
|
+
id: {
|
|
17
|
+
type: String,
|
|
18
|
+
required: true,
|
|
19
|
+
},
|
|
20
|
+
data: {
|
|
21
|
+
type: Object,
|
|
22
|
+
required: true,
|
|
23
|
+
},
|
|
24
|
+
unit: {
|
|
25
|
+
type: String,
|
|
26
|
+
default: "Count",
|
|
27
|
+
},
|
|
28
|
+
width: {
|
|
29
|
+
type: Number,
|
|
30
|
+
default: 350,
|
|
31
|
+
},
|
|
32
|
+
height: {
|
|
33
|
+
type: Number,
|
|
34
|
+
default: 200,
|
|
35
|
+
},
|
|
36
|
+
pannable: {
|
|
37
|
+
type: Boolean,
|
|
38
|
+
default: true,
|
|
39
|
+
},
|
|
40
|
+
theme: {
|
|
41
|
+
type: String,
|
|
42
|
+
default: "light",
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
data() {
|
|
46
|
+
return {
|
|
47
|
+
svg: null,
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
mounted() {
|
|
51
|
+
this.initializeChart();
|
|
52
|
+
this.createChart(this.data);
|
|
53
|
+
},
|
|
54
|
+
methods: {
|
|
55
|
+
initializeChart() {
|
|
56
|
+
this.svg = d3
|
|
57
|
+
.select("#" + this.id)
|
|
58
|
+
.append("svg")
|
|
59
|
+
.attr("width", this.width)
|
|
60
|
+
.attr("height", this.height);
|
|
61
|
+
},
|
|
62
|
+
createChart(rawData) {
|
|
63
|
+
let data = [];
|
|
64
|
+
rawData.series.forEach((d, i) => {
|
|
65
|
+
data.push({
|
|
66
|
+
...d,
|
|
67
|
+
index: i,
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
// Declare the chart dimensions and margins.
|
|
71
|
+
const width = this.width;
|
|
72
|
+
const height = this.height;
|
|
73
|
+
const marginTop = 20;
|
|
74
|
+
const marginRight = 15;
|
|
75
|
+
const marginBottom = 30;
|
|
76
|
+
const marginLeft = 50;
|
|
77
|
+
|
|
78
|
+
// get the longest slots array and largest value
|
|
79
|
+
const hidden = [];
|
|
80
|
+
|
|
81
|
+
// Declare the tooltip mouseover functions
|
|
82
|
+
const mouseover = (event, d) => {
|
|
83
|
+
const slot = new Date(d.slots).toUTCString();
|
|
84
|
+
const value =
|
|
85
|
+
this.unit === "Bytes (B)"
|
|
86
|
+
? dataCount(d.values) + "B"
|
|
87
|
+
: this.unit === "Percent (%)"
|
|
88
|
+
? d.values.toFixed(2) + "%"
|
|
89
|
+
: humanCount(d.values);
|
|
90
|
+
const text = d.action
|
|
91
|
+
? `${d.action}<br>Time: ${slot}<br>Value: ${value}`
|
|
92
|
+
: `Alert<br>Time: ${slot}<br>Value: ${value}`;
|
|
93
|
+
event.target.r.baseVal.value = 5;
|
|
94
|
+
d3.select("#" + this.id + "tooltip")
|
|
95
|
+
.html(text)
|
|
96
|
+
.style("opacity", 1)
|
|
97
|
+
.style("left", event.layerX + "px")
|
|
98
|
+
.style("top", event.layerY + "px");
|
|
99
|
+
};
|
|
100
|
+
const mouseout = (event, d) => {
|
|
101
|
+
event.target.r.baseVal.value = 3;
|
|
102
|
+
d3.select("#" + this.id + "tooltip")
|
|
103
|
+
.style("opacity", 0)
|
|
104
|
+
.style("left", "0px")
|
|
105
|
+
.style("top", "0px");
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const drawAxis = () => {
|
|
109
|
+
const dat = data.filter((d) => !hidden.includes(d.index));
|
|
110
|
+
const axisVals = this.getAxisLargest(dat);
|
|
111
|
+
// Declare the x (horizontal position) scale.
|
|
112
|
+
const x = d3.scaleUtc(d3.extent(axisVals[0]), [
|
|
113
|
+
marginLeft,
|
|
114
|
+
width - marginRight,
|
|
115
|
+
]);
|
|
116
|
+
|
|
117
|
+
// Declare the y (vertical position) scale.
|
|
118
|
+
const y = d3.scaleLinear(
|
|
119
|
+
[0, axisVals[1]],
|
|
120
|
+
[height - marginBottom, marginTop]
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
// Add the x-axis.
|
|
124
|
+
const xAxis = this.svg
|
|
125
|
+
.append("g")
|
|
126
|
+
.attr("class", this.id + "xaxis")
|
|
127
|
+
.attr("transform", `translate(0,${height - marginBottom})`)
|
|
128
|
+
.call(
|
|
129
|
+
d3
|
|
130
|
+
.axisBottom(x)
|
|
131
|
+
.ticks(width / 80)
|
|
132
|
+
.tickSizeOuter(0)
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
// Add the y-axis, remove the domain line, add grid lines and a label.
|
|
136
|
+
const yAxis = this.svg
|
|
137
|
+
.append("g")
|
|
138
|
+
.attr("class", this.id + "yaxis")
|
|
139
|
+
.attr("transform", `translate(${marginLeft},0)`)
|
|
140
|
+
.call(
|
|
141
|
+
d3
|
|
142
|
+
.axisLeft(y)
|
|
143
|
+
.ticks(height / 40)
|
|
144
|
+
.tickFormat((d) => {
|
|
145
|
+
return this.unit === "Bytes (B)" ? dataCount(d) : humanCount(d);
|
|
146
|
+
})
|
|
147
|
+
)
|
|
148
|
+
.call((g) => g.select(".domain").remove())
|
|
149
|
+
.call((g) =>
|
|
150
|
+
g
|
|
151
|
+
.selectAll(".tick line")
|
|
152
|
+
.clone()
|
|
153
|
+
.attr("x2", width - marginLeft - marginRight)
|
|
154
|
+
.attr("stroke-opacity", 0.1)
|
|
155
|
+
)
|
|
156
|
+
.call((g) =>
|
|
157
|
+
g
|
|
158
|
+
.append("text")
|
|
159
|
+
.attr("x", -marginLeft)
|
|
160
|
+
.attr("y", 10)
|
|
161
|
+
.attr("fill", "currentColor")
|
|
162
|
+
.attr("text-anchor", "start")
|
|
163
|
+
.text(this.unit)
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
// add brush to chart
|
|
167
|
+
if (this.pannable) {
|
|
168
|
+
let idleTimeout;
|
|
169
|
+
function idled() {
|
|
170
|
+
idleTimeout = null;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const updateChart = (event, d) => {
|
|
174
|
+
const extent = event.selection;
|
|
175
|
+
if (!extent) {
|
|
176
|
+
if (!idleTimeout) return (idleTimeout = setTimeout(idled, 500));
|
|
177
|
+
x.domain(d3.extent(rawData.slots));
|
|
178
|
+
} else {
|
|
179
|
+
x.domain([x.invert(extent[0]), x.invert(extent[1])]);
|
|
180
|
+
this.svg.select("." + this.id + "brush").call(brush.move, null);
|
|
181
|
+
}
|
|
182
|
+
xAxis.transition().duration(1000).call(d3.axisBottom(x));
|
|
183
|
+
this.svg.selectAll("." + this.id + "line").attr("d", function (d) {
|
|
184
|
+
return line(
|
|
185
|
+
d.values.map((val, i) => {
|
|
186
|
+
return { slots: rawData.slots[i], values: val };
|
|
187
|
+
})
|
|
188
|
+
);
|
|
189
|
+
});
|
|
190
|
+
this.svg
|
|
191
|
+
.selectAll("." + this.id + "points")
|
|
192
|
+
.attr("cx", (d) => x(d.slots));
|
|
193
|
+
};
|
|
194
|
+
const brush = d3
|
|
195
|
+
.brushX()
|
|
196
|
+
.extent([
|
|
197
|
+
[0, 0],
|
|
198
|
+
[width, height],
|
|
199
|
+
])
|
|
200
|
+
.on("end", updateChart);
|
|
201
|
+
this.svg
|
|
202
|
+
.append("g")
|
|
203
|
+
.attr("class", (d) => this.id + "brush")
|
|
204
|
+
.call(brush);
|
|
205
|
+
|
|
206
|
+
this.svg.on("dblclick", function () {
|
|
207
|
+
x.domain(
|
|
208
|
+
d3.extent(axisVals[0], function (d) {
|
|
209
|
+
return d;
|
|
210
|
+
})
|
|
211
|
+
);
|
|
212
|
+
xAxis.transition().call(d3.axisBottom(x));
|
|
213
|
+
this.svg.selectAll("." + this.id + "line").attr("d", function (d) {
|
|
214
|
+
return line(
|
|
215
|
+
d.values.map((val, i) => {
|
|
216
|
+
return { slots: rawData.slots[i], values: val };
|
|
217
|
+
})
|
|
218
|
+
);
|
|
219
|
+
});
|
|
220
|
+
this.svg
|
|
221
|
+
.selectAll("." + this.id + "points")
|
|
222
|
+
.attr("cx", (d) => x(d.slots));
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// Declare the line generator.
|
|
227
|
+
const line = d3
|
|
228
|
+
.line()
|
|
229
|
+
.x((d, i) => {
|
|
230
|
+
return x(d.slots);
|
|
231
|
+
})
|
|
232
|
+
.y((d, i) => {
|
|
233
|
+
return y(d.values);
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
this.svg
|
|
237
|
+
.selectAll(".line")
|
|
238
|
+
.data(dat)
|
|
239
|
+
.enter()
|
|
240
|
+
.append("path")
|
|
241
|
+
.attr("class", (d) => this.id + d.index + "line " + this.id + "line")
|
|
242
|
+
.attr("fill", "none")
|
|
243
|
+
.attr("z-index", 1)
|
|
244
|
+
.style(
|
|
245
|
+
"stroke",
|
|
246
|
+
(d) =>
|
|
247
|
+
alertChartColors[this.theme][d.action] ||
|
|
248
|
+
chartColors[d.index % chartColors.length]
|
|
249
|
+
)
|
|
250
|
+
.style("stroke-dasharray", "3, 3")
|
|
251
|
+
.attr("stroke-width", 1)
|
|
252
|
+
.attr("d", function (d) {
|
|
253
|
+
return line(
|
|
254
|
+
d.values.map((val, i) => {
|
|
255
|
+
return { slots: rawData.slots[i], values: val };
|
|
256
|
+
})
|
|
257
|
+
);
|
|
258
|
+
});
|
|
259
|
+
this.svg
|
|
260
|
+
.selectAll(".line")
|
|
261
|
+
.data([rawData])
|
|
262
|
+
.enter()
|
|
263
|
+
.append("path")
|
|
264
|
+
.attr("class", this.id + "line")
|
|
265
|
+
.attr("fill", "none")
|
|
266
|
+
.attr("z-index", 1)
|
|
267
|
+
.style("stroke", alertChartColors[this.theme]["Alert"])
|
|
268
|
+
.attr("stroke-width", 1.5)
|
|
269
|
+
.attr("d", function (d) {
|
|
270
|
+
return line(
|
|
271
|
+
d.slots.map((slot, i) => {
|
|
272
|
+
return { slots: slot, values: d.values[i] };
|
|
273
|
+
})
|
|
274
|
+
);
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
// add alert to chart
|
|
278
|
+
const alertData = rawData.slots.map((slot, i) => {
|
|
279
|
+
return {
|
|
280
|
+
slots: slot,
|
|
281
|
+
values: rawData.values[i],
|
|
282
|
+
isAlert: rawData.metric.bools[i],
|
|
283
|
+
};
|
|
284
|
+
});
|
|
285
|
+
this.svg
|
|
286
|
+
.selectAll(".point")
|
|
287
|
+
.data(alertData)
|
|
288
|
+
.enter()
|
|
289
|
+
.append("circle")
|
|
290
|
+
.attr("class", (d, i) => this.id + i + "points " + this.id + "points")
|
|
291
|
+
.attr("fill", chartColors[3])
|
|
292
|
+
.attr("display", (d) => (d.isAlert ? "" : "none"))
|
|
293
|
+
.attr("r", 3)
|
|
294
|
+
.attr("cx", (d) => x(d.slots))
|
|
295
|
+
.attr("cy", (d) => y(d.values))
|
|
296
|
+
.on("mouseover", mouseover)
|
|
297
|
+
.on("mouseout", mouseout);
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
drawAxis();
|
|
301
|
+
// Append a path for the line chart for each series
|
|
302
|
+
if (!rawData.series) {
|
|
303
|
+
this.svg
|
|
304
|
+
.append("text")
|
|
305
|
+
.attr("x", width / 2)
|
|
306
|
+
.attr("y", height / 2)
|
|
307
|
+
.attr("text-anchor", "middle")
|
|
308
|
+
.attr("fill", "currentColor")
|
|
309
|
+
.text("No data available");
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
if (rawData.series.length > 0) {
|
|
313
|
+
// Add a legend
|
|
314
|
+
this.legend = d3
|
|
315
|
+
.select("#" + this.id + "legend")
|
|
316
|
+
.append("svg")
|
|
317
|
+
.attr("width", this.width > 600 ? 200 : 75)
|
|
318
|
+
.attr("height", Math.max(25 * rawData.series.length, height - 20));
|
|
319
|
+
|
|
320
|
+
// Add one dot in the legend for each name.
|
|
321
|
+
this.legend
|
|
322
|
+
.selectAll("legendDots")
|
|
323
|
+
.data([...data, { action: "Alert", index: data.length }])
|
|
324
|
+
.enter()
|
|
325
|
+
.append("circle")
|
|
326
|
+
.attr("id", (d) => this.id + d.index + "dots")
|
|
327
|
+
.attr("class", "show")
|
|
328
|
+
.attr("cx", 10)
|
|
329
|
+
.attr("cy", (d, i) => height / (data.length + 2) + i * 25)
|
|
330
|
+
.attr("r", 5)
|
|
331
|
+
.style(
|
|
332
|
+
"fill",
|
|
333
|
+
(d) =>
|
|
334
|
+
alertChartColors[this.theme][d.action] ||
|
|
335
|
+
chartColors[d.index % chartColors.length]
|
|
336
|
+
);
|
|
337
|
+
|
|
338
|
+
// Add one dot in the legend for each name.
|
|
339
|
+
this.legend
|
|
340
|
+
.selectAll("legendLabels")
|
|
341
|
+
.data([...data, { action: "Alert", index: data.length }])
|
|
342
|
+
.enter()
|
|
343
|
+
.append("text")
|
|
344
|
+
.attr("class", (d) => this.id + d.index + "labels")
|
|
345
|
+
.attr("x", 20)
|
|
346
|
+
.attr("y", (d, i) => height / (data.length + 2) + i * 25)
|
|
347
|
+
.style(
|
|
348
|
+
"fill",
|
|
349
|
+
(d) =>
|
|
350
|
+
alertChartColors[this.theme][d.action] ||
|
|
351
|
+
chartColors[d.index % chartColors.length]
|
|
352
|
+
)
|
|
353
|
+
.text((d) =>
|
|
354
|
+
d.action === "Alert" ? rawData.action : d.action || "(no name)"
|
|
355
|
+
)
|
|
356
|
+
.attr("font-weight", 500)
|
|
357
|
+
.attr("text-anchor", "left")
|
|
358
|
+
.attr("font-size", "11px")
|
|
359
|
+
.style("alignment-baseline", "middle");
|
|
360
|
+
}
|
|
361
|
+
},
|
|
362
|
+
|
|
363
|
+
getAxisLargest(data) {
|
|
364
|
+
let longestSlots = this.data.slots;
|
|
365
|
+
let largestValue = Math.max(...this.data.values);
|
|
366
|
+
data.forEach((d, i) => {
|
|
367
|
+
const max = Math.max(...d.values);
|
|
368
|
+
if (max > largestValue) {
|
|
369
|
+
largestValue = max;
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
return [longestSlots, largestValue];
|
|
373
|
+
},
|
|
374
|
+
},
|
|
375
|
+
};
|
|
376
|
+
</script>
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :id="id">
|
|
3
|
+
<div :id="id + 'tooltip'" role="tooltip" class="tooltip"></div>
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
<script>
|
|
7
|
+
import * as d3 from "d3";
|
|
8
|
+
import { chartColors } from "@/constants/colors";
|
|
9
|
+
import { humanCount, dataCount, costCount } from "@/utils/formatOutput";
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
props: {
|
|
13
|
+
id: {
|
|
14
|
+
type: String,
|
|
15
|
+
required: true,
|
|
16
|
+
},
|
|
17
|
+
data: {
|
|
18
|
+
type: Object,
|
|
19
|
+
required: true,
|
|
20
|
+
},
|
|
21
|
+
unit: {
|
|
22
|
+
type: String,
|
|
23
|
+
default: "Cost ($)",
|
|
24
|
+
},
|
|
25
|
+
width: {
|
|
26
|
+
type: Number,
|
|
27
|
+
default: 800,
|
|
28
|
+
},
|
|
29
|
+
height: {
|
|
30
|
+
type: Number,
|
|
31
|
+
default: 400,
|
|
32
|
+
},
|
|
33
|
+
title: {
|
|
34
|
+
type: String,
|
|
35
|
+
default: "",
|
|
36
|
+
},
|
|
37
|
+
valueName: {
|
|
38
|
+
type: String,
|
|
39
|
+
default: "Value",
|
|
40
|
+
},
|
|
41
|
+
theme: {
|
|
42
|
+
type: String,
|
|
43
|
+
default: "light",
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
data() {
|
|
47
|
+
return {
|
|
48
|
+
svg: null,
|
|
49
|
+
};
|
|
50
|
+
},
|
|
51
|
+
mounted() {
|
|
52
|
+
this.initializeChart();
|
|
53
|
+
this.createChart(this.data);
|
|
54
|
+
},
|
|
55
|
+
methods: {
|
|
56
|
+
initializeChart() {
|
|
57
|
+
this.svg = d3
|
|
58
|
+
.select("#" + this.id)
|
|
59
|
+
.append("svg")
|
|
60
|
+
.attr("width", this.width)
|
|
61
|
+
.attr("height", this.title ? this.height + 40 : this.height);
|
|
62
|
+
},
|
|
63
|
+
createChart(data) {
|
|
64
|
+
// Declare the chart dimensions and margins.
|
|
65
|
+
const width = this.width;
|
|
66
|
+
const height = this.title ? this.height + 30 : this.height;
|
|
67
|
+
const marginTop = 20;
|
|
68
|
+
const marginRight = 15;
|
|
69
|
+
const marginBottom = 30;
|
|
70
|
+
const marginLeft = 50;
|
|
71
|
+
|
|
72
|
+
// get the largest value
|
|
73
|
+
let largestValue = this.unit === "Percent (%)" ? 100 : 0;
|
|
74
|
+
data.values.forEach((val) => {
|
|
75
|
+
if (val > largestValue) {
|
|
76
|
+
largestValue = val;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// Declare the x (horizontal position) scale.
|
|
81
|
+
const x = d3.scaleUtc(d3.extent(data.slots), [
|
|
82
|
+
marginLeft,
|
|
83
|
+
width - marginRight,
|
|
84
|
+
]);
|
|
85
|
+
|
|
86
|
+
// Declare the y (vertical position) scale.
|
|
87
|
+
const yScale = this.title
|
|
88
|
+
? [height - marginBottom, marginTop + 30]
|
|
89
|
+
: [height - marginBottom, marginTop];
|
|
90
|
+
const y = d3.scaleLinear([0, largestValue], yScale);
|
|
91
|
+
|
|
92
|
+
// Declare the tooltip mouseover functions
|
|
93
|
+
const mouseover = (event, d) => {
|
|
94
|
+
const slot = new Date(d.slots).toUTCString();
|
|
95
|
+
const value =
|
|
96
|
+
this.unit === "Bytes (B)" || this.unit === "B"
|
|
97
|
+
? dataCount(d.values) + "B"
|
|
98
|
+
: this.unit === "Percent (%)"
|
|
99
|
+
? d.values.toFixed(2) + "%"
|
|
100
|
+
: this.unit === "Cost ($)"
|
|
101
|
+
? costCount(d.values)
|
|
102
|
+
: humanCount(d.values);
|
|
103
|
+
const tooltip = d3
|
|
104
|
+
.select("#" + this.id + "tooltip")
|
|
105
|
+
.html(`${this.data.name}<br>${slot}<br>${this.valueName}: ${value}`)
|
|
106
|
+
.style("opacity", 1)
|
|
107
|
+
.style("top", event.layerY + "px");
|
|
108
|
+
if (event.layerX > (width * 3) / 4) {
|
|
109
|
+
const tooltipWidth = tooltip.node().getBoundingClientRect().width;
|
|
110
|
+
tooltip.style("left", event.layerX - tooltipWidth + "px");
|
|
111
|
+
} else {
|
|
112
|
+
tooltip.style("left", event.layerX + "px");
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
const mouseout = (event, d) => {
|
|
116
|
+
d3.select("#" + this.id + "tooltip")
|
|
117
|
+
.style("opacity", 0)
|
|
118
|
+
.style("left", "0px")
|
|
119
|
+
.style("top", "0px");
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
// Add the x-axis.
|
|
123
|
+
this.svg
|
|
124
|
+
.append("g")
|
|
125
|
+
.attr("transform", `translate(0,${height - marginBottom})`)
|
|
126
|
+
.call(
|
|
127
|
+
d3
|
|
128
|
+
.axisBottom(x)
|
|
129
|
+
.ticks(width / 80)
|
|
130
|
+
.tickSizeOuter(0)
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
// Add the y-axis, remove the domain line, add grid lines and a label.
|
|
134
|
+
this.svg
|
|
135
|
+
.append("g")
|
|
136
|
+
.attr("transform", `translate(${marginLeft},0)`)
|
|
137
|
+
.call(
|
|
138
|
+
d3
|
|
139
|
+
.axisLeft(y)
|
|
140
|
+
.ticks(height / 40)
|
|
141
|
+
.tickFormat((d) => {
|
|
142
|
+
return this.unit === "Bytes (B)" || this.unit === "B"
|
|
143
|
+
? dataCount(d)
|
|
144
|
+
: this.unit === "Cost ($)"
|
|
145
|
+
? costCount(d)
|
|
146
|
+
: humanCount(d);
|
|
147
|
+
})
|
|
148
|
+
)
|
|
149
|
+
.call((g) => g.select(".domain").remove())
|
|
150
|
+
.call((g) =>
|
|
151
|
+
g
|
|
152
|
+
.selectAll(".tick line")
|
|
153
|
+
.clone()
|
|
154
|
+
.attr("x2", width - marginLeft - marginRight)
|
|
155
|
+
.attr("stroke-opacity", 0.1)
|
|
156
|
+
)
|
|
157
|
+
.call((g) =>
|
|
158
|
+
g
|
|
159
|
+
.append("text")
|
|
160
|
+
.attr("x", -marginLeft)
|
|
161
|
+
.attr("y", this.title ? 40 : 10)
|
|
162
|
+
.attr("fill", "currentColor")
|
|
163
|
+
.attr("text-anchor", "start")
|
|
164
|
+
.text(this.unit)
|
|
165
|
+
)
|
|
166
|
+
.call((g) =>
|
|
167
|
+
g
|
|
168
|
+
.append("text")
|
|
169
|
+
.attr("x", -marginLeft)
|
|
170
|
+
.attr("y", 20)
|
|
171
|
+
.attr("fill", "currentColor")
|
|
172
|
+
.attr("text-anchor", "start")
|
|
173
|
+
.attr("font-weight", "bold")
|
|
174
|
+
.attr("font-size", "2em")
|
|
175
|
+
.text(this.title)
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
// Append a bar chart for each data point
|
|
179
|
+
if (data.slots.length > 0) {
|
|
180
|
+
const seriesData = data.slots.map((slot, i) => {
|
|
181
|
+
return {
|
|
182
|
+
slots: slot,
|
|
183
|
+
values: data.values[i],
|
|
184
|
+
};
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
this.svg
|
|
188
|
+
.selectAll(".rect")
|
|
189
|
+
.data(seriesData)
|
|
190
|
+
.enter()
|
|
191
|
+
.append("rect")
|
|
192
|
+
.attr("class", (d) => this.id + "bar")
|
|
193
|
+
.attr("z-index", 1)
|
|
194
|
+
.attr("x", (d) => x(d.slots) - 2)
|
|
195
|
+
.attr("y", (d) => y(d.values))
|
|
196
|
+
.attr("width", 10)
|
|
197
|
+
.attr("height", (d) => height - marginBottom - y(d.values))
|
|
198
|
+
.attr("fill", chartColors[0])
|
|
199
|
+
.on("mouseover", mouseover)
|
|
200
|
+
.on("mouseout", mouseout);
|
|
201
|
+
} else {
|
|
202
|
+
this.svg
|
|
203
|
+
.append("text")
|
|
204
|
+
.attr("x", width / 2)
|
|
205
|
+
.attr("y", height / 2)
|
|
206
|
+
.attr("text-anchor", "middle")
|
|
207
|
+
.text("No data available");
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
};
|
|
212
|
+
</script>
|