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.
Files changed (178) hide show
  1. package/dist/fluency-v8-components.es.js +1 -1
  2. package/dist/fluency-v8-components.umd.js +99 -99
  3. package/dist/{index-q2NbjdVo.mjs → index-BBxccHNP.mjs} +7 -6
  4. package/dist/{index.es-PAPL4E6Y.mjs → index.es-D_XhLSeH.mjs} +1 -1
  5. package/package.json +3 -2
  6. package/src/assets/images/ai.svg +1 -0
  7. package/src/assets/images/github-dark.svg +1 -0
  8. package/src/assets/images/github.svg +1 -0
  9. package/src/assets/images/high-priority.svg +1 -0
  10. package/src/assets/images/power-off.svg +1 -0
  11. package/src/assets/images/save.svg +1 -0
  12. package/src/assets/index.ts +15 -0
  13. package/src/assets/main.css +505 -0
  14. package/src/assets/prism-theme.css +290 -0
  15. package/src/components/buttons/ActionButtons.vue +374 -0
  16. package/src/components/buttons/DropdownButton.vue +104 -0
  17. package/src/components/buttons/IconButton.vue +63 -0
  18. package/src/components/buttons/ImageButton.vue +16 -0
  19. package/src/components/buttons/MenuButton.vue +138 -0
  20. package/src/components/buttons/SubmitButtons.vue +51 -0
  21. package/src/components/buttons/TextButton.vue +40 -0
  22. package/src/components/charts/AlertChart.vue +376 -0
  23. package/src/components/charts/BarChart.vue +212 -0
  24. package/src/components/charts/BarChartHorizontal.vue +243 -0
  25. package/src/components/charts/CronChart.vue +146 -0
  26. package/src/components/charts/EmptyChart.vue +76 -0
  27. package/src/components/charts/GradientChart.vue +310 -0
  28. package/src/components/charts/LineChart.test.js +59 -0
  29. package/src/components/charts/LineChart.vue +434 -0
  30. package/src/components/charts/PieChart.vue +293 -0
  31. package/src/components/charts/ProgressChart.vue +106 -0
  32. package/src/components/charts/StackedChart.vue +364 -0
  33. package/src/components/charts/StackedChartClustered.vue +395 -0
  34. package/src/components/charts/TimelineChart.vue +215 -0
  35. package/src/components/charts/WorkflowChart.vue +520 -0
  36. package/src/components/common/AutoCompleteSearchBar.vue +100 -0
  37. package/src/components/common/AutoRefreshButton.vue +53 -0
  38. package/src/components/common/Breadcrumb.vue +45 -0
  39. package/src/components/common/ButtonToggle.vue +24 -0
  40. package/src/components/common/Card.vue +116 -0
  41. package/src/components/common/Carousel.vue +66 -0
  42. package/src/components/common/CategoryCard.vue +28 -0
  43. package/src/components/common/CodeEditor.vue +59 -0
  44. package/src/components/common/DatePicker.vue +21 -0
  45. package/src/components/common/DatePickerInput.vue +109 -0
  46. package/src/components/common/Dialog.vue +103 -0
  47. package/src/components/common/EditorHeading.vue +10 -0
  48. package/src/components/common/EventList.vue +41 -0
  49. package/src/components/common/Facet.vue +206 -0
  50. package/src/components/common/Feed.vue +58 -0
  51. package/src/components/common/Flag.vue +27 -0
  52. package/src/components/common/HomeCard.vue +20 -0
  53. package/src/components/common/ItemBox.vue +49 -0
  54. package/src/components/common/Loading.vue +19 -0
  55. package/src/components/common/LoadingDots.vue +12 -0
  56. package/src/components/common/PageHeading.vue +30 -0
  57. package/src/components/common/Pagination.vue +105 -0
  58. package/src/components/common/Popover.vue +24 -0
  59. package/src/components/common/PowerToggle.vue +130 -0
  60. package/src/components/common/ProgressBar.vue +33 -0
  61. package/src/components/common/RadioButtons.vue +52 -0
  62. package/src/components/common/Schedule.vue +79 -0
  63. package/src/components/common/SearchBar.vue +30 -0
  64. package/src/components/common/Separator.vue +3 -0
  65. package/src/components/common/Slideout.vue +95 -0
  66. package/src/components/common/Sort.vue +83 -0
  67. package/src/components/common/Table.vue +48 -0
  68. package/src/components/common/Tabs.vue +129 -0
  69. package/src/components/common/Tag.vue +53 -0
  70. package/src/components/common/Tooltip.vue +49 -0
  71. package/src/components/common/VerticalTabs.vue +34 -0
  72. package/src/components/common/card/CardItem.vue +27 -0
  73. package/src/components/common/card/CardItemGroup.vue +45 -0
  74. package/src/components/common/facet/Leaf.vue +97 -0
  75. package/src/components/common/facet/TriState.vue +37 -0
  76. package/src/components/common/table/TableData.vue +48 -0
  77. package/src/components/common/table/TableHeader.vue +21 -0
  78. package/src/components/dialogs/ChooseValueDialog.vue +97 -0
  79. package/src/components/dialogs/ConfirmDialog.vue +73 -0
  80. package/src/components/dialogs/CopyDialog.vue +51 -0
  81. package/src/components/dialogs/DownloadDialog.vue +48 -0
  82. package/src/components/dialogs/NameDescDialog.vue +74 -0
  83. package/src/components/dialogs/NameDialog.vue +56 -0
  84. package/src/components/dialogs/PopupEditor.vue +113 -0
  85. package/src/components/dialogs/ProgressDialog.vue +58 -0
  86. package/src/components/dialogs/ResetPasswordDialog.vue +58 -0
  87. package/src/components/dialogs/Wizard.vue +99 -0
  88. package/src/components/dialogs/wizard/Stepper.vue +31 -0
  89. package/src/components/form/CheckBox.vue +26 -0
  90. package/src/components/form/Editor.vue +93 -0
  91. package/src/components/form/FormCol.vue +19 -0
  92. package/src/components/form/FormRow.vue +19 -0
  93. package/src/components/form/FormSection.vue +21 -0
  94. package/src/components/form/GreyForm.vue +7 -0
  95. package/src/components/form/GreyInput.vue +51 -0
  96. package/src/components/form/GreyInputAutocomplete.vue +100 -0
  97. package/src/components/form/GreyInputCopy.vue +66 -0
  98. package/src/components/form/GreyInputGrow.vue +42 -0
  99. package/src/components/form/GreyInputToken.vue +78 -0
  100. package/src/components/form/GreyPassword.vue +36 -0
  101. package/src/components/form/GreySelect.vue +154 -0
  102. package/src/components/form/GreySelectInput.vue +123 -0
  103. package/src/components/form/GreySelectInputMultiple.vue +218 -0
  104. package/src/components/form/GreyTel.vue +58 -0
  105. package/src/components/form/HamburgerItem.vue +95 -0
  106. package/src/components/form/KeyValueEntry.vue +74 -0
  107. package/src/components/form/RadioInput.vue +38 -0
  108. package/src/components/form/UploadFile.vue +99 -0
  109. package/src/components/icons/AiIcon.vue +6 -0
  110. package/src/components/icons/GithubIcon.vue +18 -0
  111. package/src/components/icons/HighPriorityIcon.vue +6 -0
  112. package/src/components/icons/PowerOffIcon.vue +6 -0
  113. package/src/components/icons/SaveIcon.vue +6 -0
  114. package/src/components/index.js +134 -0
  115. package/src/components/menu/DialogMenu.vue +142 -0
  116. package/src/components/menu/GrandChild.vue +39 -0
  117. package/src/components/menu/GridMenu.vue +88 -0
  118. package/src/components/menu/MenuAvatar.vue +66 -0
  119. package/src/components/menu/MenuDesktop.vue +90 -0
  120. package/src/components/notifications/Notify.vue +123 -0
  121. package/src/components/notifications/NotifyList.vue +130 -0
  122. package/src/components/page-structure/FacetPage.vue +77 -0
  123. package/src/components/query/Child.vue +63 -0
  124. package/src/components/query/LVDBQuery.vue +38 -0
  125. package/src/components/status/Active.vue +44 -0
  126. package/src/components/status/ScoreLevel.vue +43 -0
  127. package/src/components/status/Status.vue +51 -0
  128. package/src/components/status/TaskDot.vue +25 -0
  129. package/src/components/status/TaskStatus.vue +26 -0
  130. package/src/components/status/TicketStatus.vue +201 -0
  131. package/src/components/status/Trend.vue +20 -0
  132. package/src/components/tables/ArgumentRunTable.vue +96 -0
  133. package/src/components/tables/ArgumentTable.vue +67 -0
  134. package/src/components/tables/CloudFormationParameters.vue +25 -0
  135. package/src/constants/colors.js +248 -0
  136. package/src/constants/font-map.js +128 -0
  137. package/src/constants/fpl2.js +162 -0
  138. package/src/constants/icon-svg.js +405 -0
  139. package/src/constants/schedule.js +52 -0
  140. package/src/fpl/AddPanel.vue +237 -0
  141. package/src/fpl/Configs/Alert.vue +16 -0
  142. package/src/fpl/Configs/AlertSprite.vue +2 -0
  143. package/src/fpl/Configs/Chart.vue +63 -0
  144. package/src/fpl/Configs/Config.js +154 -0
  145. package/src/fpl/Configs/Counter.vue +35 -0
  146. package/src/fpl/Configs/Histogram.vue +70 -0
  147. package/src/fpl/Configs/IPMap.vue +37 -0
  148. package/src/fpl/Configs/Image.vue +163 -0
  149. package/src/fpl/Configs/MetricChart.vue +20 -0
  150. package/src/fpl/Configs/PieChart.vue +37 -0
  151. package/src/fpl/Configs/SparkChart.vue +41 -0
  152. package/src/fpl/Configs/StackedBarChart.vue +49 -0
  153. package/src/fpl/Configs/Table.vue +211 -0
  154. package/src/fpl/Configs/Text.vue +14 -0
  155. package/src/fpl/Configs/TopNChart.vue +37 -0
  156. package/src/fpl/Outputs/FPLAlert.vue +64 -0
  157. package/src/fpl/Outputs/FPLStream.vue +41 -0
  158. package/src/fpl/Outputs/FPLTable.vue +77 -0
  159. package/src/fpl/Panel.vue +202 -0
  160. package/src/fpl/Panels/Alert.vue +85 -0
  161. package/src/fpl/Panels/AlertSprite.vue +9 -0
  162. package/src/fpl/Panels/Chart.vue +98 -0
  163. package/src/fpl/Panels/Counter.vue +43 -0
  164. package/src/fpl/Panels/Histogram.vue +138 -0
  165. package/src/fpl/Panels/IPMap.vue +48 -0
  166. package/src/fpl/Panels/Image.vue +35 -0
  167. package/src/fpl/Panels/MetricChart.vue +97 -0
  168. package/src/fpl/Panels/PieChart.vue +54 -0
  169. package/src/fpl/Panels/SparkChart.vue +166 -0
  170. package/src/fpl/Panels/StackedBarChart.vue +74 -0
  171. package/src/fpl/Panels/Table.vue +103 -0
  172. package/src/fpl/Panels/Text.vue +24 -0
  173. package/src/fpl/Panels/TopNChart.vue +69 -0
  174. package/src/fpl/index.js +39 -0
  175. package/src/utils/download.js +220 -0
  176. package/src/utils/formatOutput.js +156 -0
  177. package/src/utils/random.js +32 -0
  178. package/src/utils/timeUtils.js +138 -0
@@ -0,0 +1,243 @@
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: 300,
28
+ },
29
+ height: {
30
+ type: Number,
31
+ default: 600,
32
+ },
33
+ title: {
34
+ type: String,
35
+ default: "",
36
+ },
37
+ resizable: {
38
+ type: Boolean,
39
+ default: false,
40
+ },
41
+ tooltipOffset: {
42
+ type: String,
43
+ default: "layer",
44
+ },
45
+ valueName: {
46
+ type: String,
47
+ default: "Value",
48
+ },
49
+ theme: {
50
+ type: String,
51
+ default: "light",
52
+ },
53
+ },
54
+ data() {
55
+ return {
56
+ svg: null,
57
+ };
58
+ },
59
+ mounted() {
60
+ this.initializeChart();
61
+ this.createChart(this.data);
62
+ },
63
+ methods: {
64
+ initializeChart() {
65
+ if (this.resizable) {
66
+ this.svg = d3
67
+ .select("#" + this.id)
68
+ .append("svg")
69
+ .attr(
70
+ "viewBox",
71
+ `0 0 ${this.width} ${this.title ? this.height + 40 : this.height}`
72
+ );
73
+ } else {
74
+ this.svg = d3
75
+ .select("#" + this.id)
76
+ .append("svg")
77
+ .attr("width", this.width)
78
+ .attr("height", this.title ? this.height + 40 : this.height);
79
+ }
80
+ },
81
+ createChart(data) {
82
+ // Declare the chart dimensions and margins.
83
+ const width = this.width;
84
+ const height = this.title ? this.height + 30 : this.height;
85
+ const marginTop = 20;
86
+ const marginRight = 5;
87
+ const marginBottom = 5;
88
+ const marginLeft = 10;
89
+
90
+ const domainMap = data.fields.reduce((acc, field, i) => {
91
+ acc[i] = field ? field : "(no name)";
92
+ return acc;
93
+ }, {});
94
+
95
+ // Declare the tooltip mouseover functions
96
+ 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);
103
+ event.target.style.opacity = 0.4;
104
+ d3.select("#" + this.id + "tooltip")
105
+ .html(
106
+ `${d.field ? d.field : "(no name)"}<br>${this.valueName}: ${value}`
107
+ )
108
+ .style("opacity", 1)
109
+ .style("left", event[this.tooltipOffset + "X"] + 10 + "px")
110
+ .style("top", event[this.tooltipOffset + "Y"] + "px");
111
+ };
112
+ const mouseoutEmpty = (event, d) => {
113
+ event.target.style.opacity = 0;
114
+ d3.select("#" + this.id + "tooltip")
115
+ .style("opacity", 0)
116
+ .style("left", "0px")
117
+ .style("top", "0px");
118
+ };
119
+
120
+ // Append a bar chart for each data point
121
+ if (data.fields && data.fields.length > 0) {
122
+ // get the largest value
123
+ let largestValue = this.unit === "Percent (%)" ? 100 : 0;
124
+ data.values.forEach((val) => {
125
+ if (val > largestValue) {
126
+ largestValue = val;
127
+ }
128
+ });
129
+ if (largestValue === 0) {
130
+ largestValue = 1;
131
+ }
132
+
133
+ // Declare the x (horizontal position) scale.
134
+ const x = d3.scaleLinear(
135
+ [0, largestValue],
136
+ [marginLeft, width - marginRight - marginLeft]
137
+ );
138
+
139
+ // Declare the y (vertical position) scale.
140
+ const yScale = this.title
141
+ ? [height - marginBottom, marginTop + 30]
142
+ : [height - marginBottom, marginTop];
143
+ const y = d3
144
+ .scaleBand()
145
+ .range(yScale)
146
+ .domain(data.fields.map((field, i) => i))
147
+ .padding(0.2);
148
+
149
+ const seriesData = data.fields.map((field, i) => {
150
+ return {
151
+ field: field,
152
+ values: data.values[i] || 0,
153
+ };
154
+ });
155
+ this.svg
156
+ .selectAll(".rect")
157
+ .data(seriesData)
158
+ .enter()
159
+ .append("rect")
160
+ .attr("class", (d) => this.id + "bar")
161
+ .attr("z-index", 1)
162
+ .attr("x", (d) => x(0))
163
+ .attr("y", (d, i) => y(i))
164
+ .attr("width", (d) => 0)
165
+ .attr("height", y.bandwidth())
166
+ .attr("fill", (d, i) => chartColors[i % chartColors.length])
167
+ .style("opacity", 0.8);
168
+ // Animation
169
+ this.svg
170
+ .selectAll("rect")
171
+ .transition()
172
+ .duration(500)
173
+ .attr("x", (d) => x(0))
174
+ .attr("width", (d) => x(d.values) - marginLeft)
175
+ .delay((d, i) => i * 50);
176
+ // empty bars for tooltip mouseover
177
+ this.svg
178
+ .selectAll(".rect")
179
+ .data(seriesData)
180
+ .enter()
181
+ .append("rect")
182
+ .attr("class", (d) => this.id + "barEmpty")
183
+ .attr("z-index", 1)
184
+ .attr("x", (d) => x(0))
185
+ .attr("y", (d, i) => y(i))
186
+ .attr("width", this.width - marginLeft)
187
+ .attr("height", y.bandwidth())
188
+ .attr("fill", (d, i) => chartColors[i % chartColors.length])
189
+ .style("opacity", 0)
190
+ .on("mouseover", mouseoverEmpty)
191
+ .on("mouseout", mouseoutEmpty);
192
+
193
+ // Add the x-axis.
194
+ this.svg
195
+ .append("g")
196
+ .attr("transform", `translate(0,${marginTop})`)
197
+ .call(
198
+ d3
199
+ .axisTop(x)
200
+ .ticks(5)
201
+ .tickFormat((d) => {
202
+ return this.unit === "Bytes (B)" || this.unit === "B"
203
+ ? dataCount(d)
204
+ : this.unit === "Cost ($)"
205
+ ? costCount(d)
206
+ : humanCount(d);
207
+ })
208
+ );
209
+ // Add the y-axis, remove the domain line, add grid lines and a label.
210
+ this.svg
211
+ .append("g")
212
+ .attr("transform", `translate(${marginLeft},0)`)
213
+ .call(
214
+ d3
215
+ .axisRight(y)
216
+ .tickSize(0)
217
+ .tickFormat((d) => {
218
+ return domainMap[d];
219
+ })
220
+ )
221
+ .call((g) => g.select(".domain").remove())
222
+ .call((g) =>
223
+ g
224
+ .append("text")
225
+ .attr("x", -marginLeft)
226
+ .attr("y", 20)
227
+ .attr("fill", "currentColor")
228
+ .attr("text-anchor", "start")
229
+ .attr("font-size", "2em")
230
+ .text(this.title)
231
+ );
232
+ } else {
233
+ this.svg
234
+ .append("text")
235
+ .attr("x", width / 2)
236
+ .attr("y", height / 2)
237
+ .attr("text-anchor", "middle")
238
+ .text("No data available");
239
+ }
240
+ },
241
+ },
242
+ };
243
+ </script>
@@ -0,0 +1,146 @@
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 { platformMetricsLabels } from "@/constants/colors";
9
+ import { formatReadableTime } from "@/utils/formatOutput";
10
+ import moment from "moment";
11
+
12
+ export default {
13
+ props: {
14
+ id: String,
15
+ tooltip: String,
16
+ runs: Array,
17
+ tooltipOffset: {
18
+ type: String,
19
+ default: "client",
20
+ },
21
+ theme: {
22
+ type: String,
23
+ default: "light",
24
+ },
25
+ },
26
+ data() {
27
+ return {
28
+ svg: null,
29
+ width: 250,
30
+ height: 60,
31
+ };
32
+ },
33
+ mounted() {
34
+ this.initializeChart();
35
+ this.createChart();
36
+ },
37
+ methods: {
38
+ initializeChart() {
39
+ this.svg = d3
40
+ .select("#" + this.id)
41
+ .append("svg")
42
+ .attr("width", this.width)
43
+ .attr("height", this.height)
44
+ .attr("style", "outline: thin solid;");
45
+ },
46
+ createChart() {
47
+ // Declare the chart dimensions and margins.
48
+ const width = this.width;
49
+ const height = this.height;
50
+ const marginTop = 3;
51
+ const marginRight = 18;
52
+ const marginBottom = 17;
53
+ const marginLeft = 18;
54
+
55
+ const mouseover = (event, d) => {
56
+ d3.selectAll("." + this.id + "run").attr("opacity", "0.5");
57
+ d3.select("." + this.id + d.taskID).attr("opacity", "1");
58
+ const launchTime = moment(d.launchTime).format("YYYY-MM-DD HH:mm:ss");
59
+ const completeTime = moment(d.completeTime).format(
60
+ "YYYY-MM-DD HH:mm:ss"
61
+ );
62
+ const timetaken = moment(d.completeTime).diff(moment(d.launchTime));
63
+ const text = `Task: ${d.taskID}<br>Status: ${
64
+ d.status
65
+ }<br>Launch Time: ${launchTime}<br>Complete Time: ${completeTime}<br>Duration: ${formatReadableTime(
66
+ timetaken
67
+ )}`;
68
+ d3.select("#" + this.id + "tooltip")
69
+ .html(text)
70
+ .style("opacity", 1)
71
+ .style("left", event[this.tooltipOffset + "X"] + 10 + "px")
72
+ .style("top", event[this.tooltipOffset + "Y"] + "px");
73
+ };
74
+ const mouseout = (event, d) => {
75
+ d3.selectAll("." + this.id + "run").attr("opacity", "1");
76
+ d3.select("#" + this.id + "tooltip")
77
+ .style("opacity", 0)
78
+ .style("left", "0px")
79
+ .style("top", "0px");
80
+ };
81
+
82
+ // get the x scale
83
+ const slots = this.runs.map((run) => moment(run.launchTime).valueOf());
84
+ if (slots.length === 1) {
85
+ slots.push(moment(slots[0]).add(2, "minute").valueOf());
86
+ slots.push(moment(slots[0]).subtract(2, "minute").valueOf());
87
+ }
88
+ const x = d3.scaleTime(d3.extent(slots), [
89
+ marginLeft,
90
+ width - marginRight,
91
+ ]);
92
+ // Add the x-axis.
93
+ this.svg
94
+ .append("g")
95
+ .attr("class", this.id + "xaxis")
96
+ .attr("transform", `translate(0,${height - marginBottom})`)
97
+ .call(
98
+ d3
99
+ .axisBottom(x)
100
+ .ticks(width / 80)
101
+ .tickSize(3)
102
+ .tickSizeOuter(0)
103
+ );
104
+ // Add the runs
105
+ this.svg
106
+ .selectAll(".rect")
107
+ .data(this.runs)
108
+ .enter()
109
+ .append("rect")
110
+ .attr("class", (d) => this.id + "run " + `${this.id}${d.taskID}`)
111
+ .attr("style", "cursor: pointer;")
112
+ .attr("z-index", 1)
113
+ .attr("x", (d) => x(moment(d.launchTime).valueOf()))
114
+ .attr("y", marginTop)
115
+ .attr("width", (d) => {
116
+ const runWidth =
117
+ x(moment(d.completeTime).valueOf()) -
118
+ x(moment(d.launchTime).valueOf());
119
+ return runWidth > 3.5 ? runWidth : 3.5;
120
+ })
121
+ .attr("height", (d) => height - marginBottom - marginTop)
122
+ .attr("fill", (d) => {
123
+ const status =
124
+ d.status === "completed"
125
+ ? "input"
126
+ : d.status === "aborted"
127
+ ? "error"
128
+ : "ignored";
129
+ return platformMetricsLabels[this.theme][status];
130
+ })
131
+ .attr("opacity", 0)
132
+ .on("click", (event, d) => {
133
+ this.$emit("viewRun", d);
134
+ })
135
+ .on("mouseover", mouseover)
136
+ .on("mouseout", mouseout)
137
+ .transition()
138
+ .delay((d, i) => {
139
+ return 1000 - (i / this.runs.length) * 1200;
140
+ })
141
+ .duration(200)
142
+ .attr("opacity", 1);
143
+ },
144
+ },
145
+ };
146
+ </script>
@@ -0,0 +1,76 @@
1
+ <template>
2
+ <div :id="id" />
3
+ </template>
4
+ <script>
5
+ import * as d3 from "d3";
6
+
7
+ export default {
8
+ props: {
9
+ id: {
10
+ type: String,
11
+ required: true,
12
+ },
13
+ width: {
14
+ type: Number,
15
+ default: 350,
16
+ },
17
+ height: {
18
+ type: Number,
19
+ default: 200,
20
+ },
21
+ },
22
+ data() {
23
+ return {
24
+ svg: null,
25
+ };
26
+ },
27
+ mounted() {
28
+ this.initializeChart();
29
+ this.createChart();
30
+ },
31
+ methods: {
32
+ initializeChart() {
33
+ this.svg = d3
34
+ .select("#" + this.id)
35
+ .append("svg")
36
+ .attr("width", this.width > 700 ? this.width + 150 : this.width + 75)
37
+ .attr("height", this.height);
38
+ },
39
+ createChart() {
40
+ // Declare the chart dimensions and margins.
41
+ const width = this.width;
42
+ const height = this.height;
43
+ const marginTop = 20;
44
+ const marginRight = 15;
45
+ const marginBottom = 1;
46
+ const marginLeft = 0.3;
47
+
48
+ const x = d3.scaleUtc([0, 1], [marginLeft, width - marginRight]);
49
+
50
+ // Declare the y (vertical position) scale.
51
+ const y = d3.scaleLinear([0, 1], [height - marginBottom, marginTop]);
52
+
53
+ this.svg
54
+ .append("g")
55
+ .attr("class", this.id + "xaxis")
56
+ .attr("transform", `translate(0,${height - marginBottom})`)
57
+ .call(d3.axisBottom(x));
58
+
59
+ // Add the y-axis, remove the domain line, add grid lines and a label.
60
+ this.svg
61
+ .append("g")
62
+ .attr("class", this.id + "yaxis")
63
+ .attr("transform", `translate(${marginLeft},0)`)
64
+ .call(d3.axisLeft(y));
65
+
66
+ this.svg
67
+ .append("text")
68
+ .attr("x", width / 2)
69
+ .attr("y", height / 2)
70
+ .attr("text-anchor", "middle")
71
+ .attr("fill", "currentColor")
72
+ .text("No data available");
73
+ },
74
+ },
75
+ };
76
+ </script>