fluency-v8-components 1.3.4 → 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 +31 -31
- package/dist/{index-Dxs_Gn5T.mjs → index-BBxccHNP.mjs} +53 -47
- package/dist/index.css +1 -1
- package/dist/{index.es-YeMpD96e.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,364 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :id="id">
|
|
3
|
+
<div :id="id + 'tooltip'" role="tooltip" class="tooltip"></div>
|
|
4
|
+
</div>
|
|
5
|
+
<div class="overflow-auto" :style="`width: ${width}px; overflow: auto`">
|
|
6
|
+
<div :id="id + 'legend'"></div>
|
|
7
|
+
</div>
|
|
8
|
+
</template>
|
|
9
|
+
<script>
|
|
10
|
+
import * as d3 from "d3";
|
|
11
|
+
import { costLabels, chartColors } from "@/constants/colors";
|
|
12
|
+
import { humanCount, dataCount, costCount } from "@/utils/formatOutput";
|
|
13
|
+
import { adjustText } from "@/constants/font-map";
|
|
14
|
+
|
|
15
|
+
export default {
|
|
16
|
+
props: {
|
|
17
|
+
id: {
|
|
18
|
+
type: String,
|
|
19
|
+
required: true,
|
|
20
|
+
},
|
|
21
|
+
data: {
|
|
22
|
+
type: Object,
|
|
23
|
+
required: true,
|
|
24
|
+
},
|
|
25
|
+
unit: {
|
|
26
|
+
type: String,
|
|
27
|
+
default: "Cost ($)",
|
|
28
|
+
},
|
|
29
|
+
width: {
|
|
30
|
+
type: Number,
|
|
31
|
+
default: 575,
|
|
32
|
+
},
|
|
33
|
+
height: {
|
|
34
|
+
type: Number,
|
|
35
|
+
default: 350,
|
|
36
|
+
},
|
|
37
|
+
title: {
|
|
38
|
+
type: String,
|
|
39
|
+
default: "",
|
|
40
|
+
},
|
|
41
|
+
names: {
|
|
42
|
+
type: Object,
|
|
43
|
+
default: () => {},
|
|
44
|
+
},
|
|
45
|
+
isTime: {
|
|
46
|
+
type: Boolean,
|
|
47
|
+
default: true,
|
|
48
|
+
},
|
|
49
|
+
tooltipOffset: {
|
|
50
|
+
type: String,
|
|
51
|
+
default: "layer",
|
|
52
|
+
},
|
|
53
|
+
slotName: {
|
|
54
|
+
type: String,
|
|
55
|
+
default: "Field",
|
|
56
|
+
},
|
|
57
|
+
valueName: {
|
|
58
|
+
type: String,
|
|
59
|
+
default: "Value",
|
|
60
|
+
},
|
|
61
|
+
theme: {
|
|
62
|
+
type: String,
|
|
63
|
+
default: "light",
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
data() {
|
|
67
|
+
return {
|
|
68
|
+
svg: null,
|
|
69
|
+
legend: null,
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
mounted() {
|
|
73
|
+
this.initializeChart();
|
|
74
|
+
this.createChart(this.data);
|
|
75
|
+
},
|
|
76
|
+
methods: {
|
|
77
|
+
initializeChart() {
|
|
78
|
+
this.svg = d3
|
|
79
|
+
.select("#" + this.id)
|
|
80
|
+
.append("svg")
|
|
81
|
+
.attr("width", this.width)
|
|
82
|
+
.attr("height", this.title ? this.height + 30 : this.height);
|
|
83
|
+
},
|
|
84
|
+
createChart(data) {
|
|
85
|
+
// Declare the chart dimensions and margins.
|
|
86
|
+
const width = this.width;
|
|
87
|
+
const height = this.title ? this.height + 30 : this.height;
|
|
88
|
+
const marginTop = 20;
|
|
89
|
+
const marginRight = 15;
|
|
90
|
+
const marginBottom = 30;
|
|
91
|
+
const marginLeft = 50;
|
|
92
|
+
|
|
93
|
+
const hidden = [];
|
|
94
|
+
const namesIndex = Object.keys(this.names);
|
|
95
|
+
|
|
96
|
+
// Declare the tooltip mouseover functions
|
|
97
|
+
const mouseover = (event, d) => {
|
|
98
|
+
const slot = this.isTime
|
|
99
|
+
? new Date(d.data[0]).toUTCString()
|
|
100
|
+
: d.data[0];
|
|
101
|
+
const val = d[1] - d[0];
|
|
102
|
+
const title = this.names[d.key] || d.key;
|
|
103
|
+
const value =
|
|
104
|
+
this.unit === "Bytes (B)"
|
|
105
|
+
? dataCount(val) + "B"
|
|
106
|
+
: this.unit === "Percent (%)"
|
|
107
|
+
? val.toFixed(2) + "%"
|
|
108
|
+
: this.unit === "Cost ($)"
|
|
109
|
+
? "$" + val.toFixed(2)
|
|
110
|
+
: humanCount(val);
|
|
111
|
+
event.target.style.opacity = 0.7;
|
|
112
|
+
d3.select("#" + this.id + "tooltip")
|
|
113
|
+
.html(
|
|
114
|
+
`${title}<br>${this.isTime ? "Time" : this.slotName}: ${slot}<br>${
|
|
115
|
+
this.valueName
|
|
116
|
+
}: ${value}`
|
|
117
|
+
)
|
|
118
|
+
.style("opacity", 1)
|
|
119
|
+
.style("left", event[this.tooltipOffset + "X"] + 10 + "px")
|
|
120
|
+
.style("top", event[this.tooltipOffset + "Y"] + "px");
|
|
121
|
+
};
|
|
122
|
+
const mouseout = (event, d) => {
|
|
123
|
+
event.target.style.opacity = 1;
|
|
124
|
+
d3.select("#" + this.id + "tooltip")
|
|
125
|
+
.style("opacity", 0)
|
|
126
|
+
.style("left", "0px")
|
|
127
|
+
.style("top", "0px");
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
// Declare the legend mouseover functions
|
|
131
|
+
const legendMouseover = (event, d) => {
|
|
132
|
+
const action = namesIndex.indexOf(d.key);
|
|
133
|
+
d3.selectAll("." + this.id + "bar").style("opacity", 0.7);
|
|
134
|
+
d3.selectAll("." + this.id + action + "bar").style("opacity", 1);
|
|
135
|
+
d3.selectAll("#" + this.id + action + "dots").attr("r", 6);
|
|
136
|
+
d3.selectAll("." + this.id + action + "labels").attr(
|
|
137
|
+
"font-weight",
|
|
138
|
+
1000
|
|
139
|
+
);
|
|
140
|
+
};
|
|
141
|
+
const legendMouseout = (event, d) => {
|
|
142
|
+
const action = namesIndex.indexOf(d.key);
|
|
143
|
+
d3.selectAll("." + this.id + "bar").style("opacity", 1);
|
|
144
|
+
d3.selectAll("#" + this.id + action + "dots").attr("r", 5);
|
|
145
|
+
d3.selectAll("." + this.id + action + "labels").attr(
|
|
146
|
+
"font-weight",
|
|
147
|
+
500
|
|
148
|
+
);
|
|
149
|
+
};
|
|
150
|
+
const legendClick = (event, d) => {
|
|
151
|
+
const action = namesIndex.indexOf(d.key);
|
|
152
|
+
// redraw the axis and the series
|
|
153
|
+
d3.select("." + this.id + "xaxis").remove();
|
|
154
|
+
d3.select("." + this.id + "yaxis").remove();
|
|
155
|
+
d3.selectAll("#" + this.id + " rect").remove();
|
|
156
|
+
if (event.target.classList.contains("show")) {
|
|
157
|
+
hidden.push(d.key);
|
|
158
|
+
event.target.classList.remove("show");
|
|
159
|
+
event.target.classList.add("hide");
|
|
160
|
+
d3.selectAll("#" + this.id + action + "dots").attr("opacity", "0.5");
|
|
161
|
+
} else {
|
|
162
|
+
hidden.splice(hidden.indexOf(d.key), 1);
|
|
163
|
+
event.target.classList.remove("hide");
|
|
164
|
+
event.target.classList.add("show");
|
|
165
|
+
d3.selectAll("#" + this.id + action + "dots").attr("opacity", "1");
|
|
166
|
+
}
|
|
167
|
+
drawChart();
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
const drawChart = () => {
|
|
171
|
+
const seriesVals = data.series.filter((d) => !hidden.includes(d.name));
|
|
172
|
+
const series = d3
|
|
173
|
+
.stack()
|
|
174
|
+
.keys(d3.union(seriesVals.map((d) => d.name)))
|
|
175
|
+
.value((d, key) => {
|
|
176
|
+
if (d[1].get(key) === undefined) {
|
|
177
|
+
return 0;
|
|
178
|
+
}
|
|
179
|
+
return d[1].get(key).value;
|
|
180
|
+
})(
|
|
181
|
+
d3.index(
|
|
182
|
+
seriesVals,
|
|
183
|
+
(d) => d.slot,
|
|
184
|
+
(d) => d.name
|
|
185
|
+
)
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
// Declare the x (horizontal position) scale.
|
|
189
|
+
const x = this.isTime
|
|
190
|
+
? d3.scaleUtc(d3.extent(data.slots), [
|
|
191
|
+
marginLeft,
|
|
192
|
+
width - marginRight,
|
|
193
|
+
])
|
|
194
|
+
: d3.scaleBand(data.slots, [marginLeft, width - marginRight]);
|
|
195
|
+
|
|
196
|
+
// Declare the y (vertical position) scale.
|
|
197
|
+
const yScale = this.title
|
|
198
|
+
? [height - marginBottom, marginTop + 30]
|
|
199
|
+
: [height - marginBottom, marginTop];
|
|
200
|
+
const y = d3.scaleLinear(
|
|
201
|
+
[0, d3.max(series, (d) => d3.max(d, (d) => d[1]))],
|
|
202
|
+
yScale
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
// Add the x-axis.
|
|
206
|
+
this.svg
|
|
207
|
+
.append("g")
|
|
208
|
+
.attr("transform", `translate(0,${height - marginBottom})`)
|
|
209
|
+
.attr("class", this.id + "xaxis")
|
|
210
|
+
.call(
|
|
211
|
+
this.isTime
|
|
212
|
+
? d3
|
|
213
|
+
.axisBottom(x)
|
|
214
|
+
.ticks(width / 80)
|
|
215
|
+
.tickSizeOuter(0)
|
|
216
|
+
: d3
|
|
217
|
+
.axisBottom(x)
|
|
218
|
+
.ticks(width / 20)
|
|
219
|
+
.tickSizeOuter(0)
|
|
220
|
+
.tickFormat((d) => {
|
|
221
|
+
if (!this.isTime) {
|
|
222
|
+
return adjustText(
|
|
223
|
+
d,
|
|
224
|
+
((width - marginRight) / data.slots.length) * 8
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
})
|
|
228
|
+
);
|
|
229
|
+
|
|
230
|
+
// Add the y-axis, remove the domain line, add grid lines and a label.
|
|
231
|
+
this.svg
|
|
232
|
+
.append("g")
|
|
233
|
+
.attr("transform", `translate(${marginLeft},0)`)
|
|
234
|
+
.attr("class", this.id + "yaxis")
|
|
235
|
+
.call(
|
|
236
|
+
d3
|
|
237
|
+
.axisLeft(y)
|
|
238
|
+
.ticks(height / 40)
|
|
239
|
+
.tickFormat((d) => {
|
|
240
|
+
return this.unit === "Bytes (B)"
|
|
241
|
+
? dataCount(d)
|
|
242
|
+
: this.unit === "Cost ($)"
|
|
243
|
+
? costCount(d)
|
|
244
|
+
: humanCount(d);
|
|
245
|
+
})
|
|
246
|
+
)
|
|
247
|
+
.call((g) => g.select(".domain").remove())
|
|
248
|
+
.call((g) =>
|
|
249
|
+
g
|
|
250
|
+
.selectAll(".tick line")
|
|
251
|
+
.clone()
|
|
252
|
+
.attr("x2", width - marginLeft - marginRight)
|
|
253
|
+
.attr("stroke-opacity", 0.1)
|
|
254
|
+
)
|
|
255
|
+
.call((g) =>
|
|
256
|
+
g
|
|
257
|
+
.append("text")
|
|
258
|
+
.attr("x", -marginLeft)
|
|
259
|
+
.attr("y", this.title ? 40 : 10)
|
|
260
|
+
.attr("fill", "currentColor")
|
|
261
|
+
.attr("text-anchor", "start")
|
|
262
|
+
.text(this.unit)
|
|
263
|
+
);
|
|
264
|
+
|
|
265
|
+
this.svg
|
|
266
|
+
.append("g")
|
|
267
|
+
.selectAll()
|
|
268
|
+
.data(series)
|
|
269
|
+
.join("g")
|
|
270
|
+
.attr(
|
|
271
|
+
"fill",
|
|
272
|
+
(d) =>
|
|
273
|
+
costLabels[this.theme][d.key] ||
|
|
274
|
+
chartColors[namesIndex.indexOf(d.key) % chartColors.length]
|
|
275
|
+
)
|
|
276
|
+
.selectAll("rect")
|
|
277
|
+
.data((D) => D.map((d) => ((d.key = D.key), d)))
|
|
278
|
+
.join("rect")
|
|
279
|
+
.attr("class", (d) => {
|
|
280
|
+
const i = namesIndex.indexOf(d.key);
|
|
281
|
+
return `${this.id}${i}bar ${this.id}bar`;
|
|
282
|
+
})
|
|
283
|
+
.attr("x", (d) => x(d.data[0]))
|
|
284
|
+
.attr("y", (d) => y(d[1]))
|
|
285
|
+
.attr("height", (d) => y(d[0]) - y(d[1]))
|
|
286
|
+
.attr("width", this.isTime ? 15 : Math.max(x.step() - 5, 15))
|
|
287
|
+
.on("mouseover", mouseover)
|
|
288
|
+
.on("mouseout", mouseout);
|
|
289
|
+
return series;
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
const series = drawChart(data);
|
|
293
|
+
this.svg
|
|
294
|
+
.append("g")
|
|
295
|
+
.call((g) =>
|
|
296
|
+
g
|
|
297
|
+
.append("text")
|
|
298
|
+
.attr("x", 0)
|
|
299
|
+
.attr("y", 20)
|
|
300
|
+
.attr("fill", "currentColor")
|
|
301
|
+
.attr("text-anchor", "start")
|
|
302
|
+
.attr("font-weight", "bold")
|
|
303
|
+
.attr("font-size", "20px")
|
|
304
|
+
.text(this.title)
|
|
305
|
+
);
|
|
306
|
+
if (data.series.length === 0) {
|
|
307
|
+
this.svg
|
|
308
|
+
.append("text")
|
|
309
|
+
.attr("x", width / 2)
|
|
310
|
+
.attr("y", height / 2)
|
|
311
|
+
.attr("text-anchor", "middle")
|
|
312
|
+
.text("No data available")
|
|
313
|
+
.attr("fill", "currentColor");
|
|
314
|
+
}
|
|
315
|
+
// Add a legend
|
|
316
|
+
this.legend = d3
|
|
317
|
+
.select("#" + this.id + "legend")
|
|
318
|
+
.append("svg")
|
|
319
|
+
.attr("width", Math.max(this.width, series.length * 125))
|
|
320
|
+
.attr("height", 20);
|
|
321
|
+
|
|
322
|
+
// Add one dot in the legend for each name.
|
|
323
|
+
this.legend
|
|
324
|
+
.selectAll("legendDots")
|
|
325
|
+
.data(series)
|
|
326
|
+
.enter()
|
|
327
|
+
.append("circle")
|
|
328
|
+
.attr("id", (d) => this.id + namesIndex.indexOf(d.key) + "dots")
|
|
329
|
+
.attr("class", "show")
|
|
330
|
+
.attr("cx", (d, i) => width / (series.length + 1) + i * 120 - 10)
|
|
331
|
+
.attr("cy", 15)
|
|
332
|
+
.attr("r", 5)
|
|
333
|
+
.attr(
|
|
334
|
+
"fill",
|
|
335
|
+
(d, i) =>
|
|
336
|
+
costLabels[this.theme][d.key] || chartColors[i % chartColors.length]
|
|
337
|
+
)
|
|
338
|
+
.on("mouseover", legendMouseover)
|
|
339
|
+
.on("mouseout", legendMouseout)
|
|
340
|
+
.on("click", legendClick);
|
|
341
|
+
|
|
342
|
+
// Add one dot in the legend for each name.
|
|
343
|
+
this.legend
|
|
344
|
+
.selectAll("legendLabels")
|
|
345
|
+
.data(series)
|
|
346
|
+
.enter()
|
|
347
|
+
.append("text")
|
|
348
|
+
.attr("class", (d) => this.id + namesIndex.indexOf(d.key) + "labels")
|
|
349
|
+
.attr("x", (d, i) => width / (series.length + 1) + i * 120)
|
|
350
|
+
.attr("y", 15)
|
|
351
|
+
.attr(
|
|
352
|
+
"fill",
|
|
353
|
+
(d, i) =>
|
|
354
|
+
costLabels[this.theme][d.key] || chartColors[i % chartColors.length]
|
|
355
|
+
)
|
|
356
|
+
.text((d, i) => adjustText(this.names[d[0].key], 700))
|
|
357
|
+
.attr("font-weight", 500)
|
|
358
|
+
.attr("text-anchor", "left")
|
|
359
|
+
.attr("font-size", "11px")
|
|
360
|
+
.style("alignment-baseline", "middle");
|
|
361
|
+
},
|
|
362
|
+
},
|
|
363
|
+
};
|
|
364
|
+
</script>
|