bfg-common 1.4.37 → 1.4.38

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.
@@ -1,109 +1,110 @@
1
- <template>
2
- <div class="graph-content">
3
- <template v-if="chartOptions">
4
- <client-only>
5
- <highchart
6
- :options="chartOptions"
7
- :modules="['exporting', 'export-data']"
8
- class="graph-block"
9
- />
10
- </client-only>
11
- </template>
12
- </div>
13
- </template>
14
-
15
- <script setup lang="ts">
16
- import type {
17
- I_LineGraph,
18
- I_DiskGraph,
19
- } from 'bfg-nuxt-3-graph/graph/lib/models/interfaces'
20
-
21
- const props = defineProps<{
22
- chart?: any
23
- data: I_LineGraph | I_DiskGraph
24
- update: number
25
- exportType?: string
26
- selectedRow?: number[]
27
- }>()
28
-
29
- let localChart: any = null
30
- const exportChart = (type: string): void => {
31
- if (type === 'png') {
32
- localChart.exportChart({
33
- type: 'image/png',
34
- })
35
- } else if (type === 'jpeg') {
36
- localChart.exportChart({
37
- type: 'image/jpeg',
38
- })
39
- } else if (type === 'svg') {
40
- localChart.exportChart({
41
- type: 'image/svg+xml',
42
- })
43
- } else if (type === 'csv') {
44
- localChart.downloadCSV()
45
- }
46
- }
47
-
48
- const chartOptions = ref<I_LineGraph | I_DiskGraph | null>(null)
49
- const initGraph = (): void => {
50
- if (!props.data) return
51
- setTimeout(() => {
52
- chartOptions.value = props.data
53
- }, 500)
54
- }
55
-
56
- watch(
57
- () => props.update,
58
- (newValue) => {
59
- newValue && initGraph()
60
- },
61
- { immediate: true }
62
- )
63
-
64
- watch(
65
- () => props.exportType,
66
- (newValue) => {
67
- if (!newValue) return
68
-
69
- exportChart(newValue)
70
- }
71
- )
72
-
73
- watch(
74
- () => props.chart,
75
- (newValue) => {
76
- if (newValue.series) localChart = newValue
77
- },
78
- { deep: true }
79
- )
80
-
81
- const updateSeriesStrokeWidth = (data: number[]): void => {
82
- if (!localChart) return
83
-
84
- localChart.series.forEach((_: any, key: number) => {
85
- localChart.options.series[key].lineWidth = 1.5
86
-
87
- if (data.includes(key)) localChart.options.series[key].lineWidth = 3
88
- })
89
-
90
- localChart.update(localChart.options)
91
- }
92
-
93
- watch(
94
- () => props.selectedRow,
95
- (newValue) => newValue && updateSeriesStrokeWidth(newValue)
96
- )
97
- </script>
98
-
99
- <style scoped lang="scss">
100
- .graph-content {
101
- width: 100%;
102
- //height: inherit;
103
- height: 100%;
104
-
105
- .graph-block {
106
- height: 100%;
107
- }
108
- }
109
- </style>
1
+ <template>
2
+ <div class="graph-content">
3
+ <template v-if="chartOptions">
4
+ <client-only>
5
+ <highchart
6
+ :options="chartOptions"
7
+ :modules="['exporting', 'export-data']"
8
+ class="graph-block"
9
+ />
10
+ </client-only>
11
+ </template>
12
+ </div>
13
+ </template>
14
+
15
+ <script setup lang="ts">
16
+ import type {
17
+ I_LineGraph,
18
+ I_DiskGraph,
19
+ } from 'bfg-nuxt-3-graph/graph/lib/models/interfaces'
20
+
21
+ const props = defineProps<{
22
+ chart?: any
23
+ data: I_LineGraph | I_DiskGraph
24
+ update: number
25
+ exportType?: string
26
+ selectedRow?: number[]
27
+ }>()
28
+
29
+ let localChart: any = null
30
+ const exportChart = (type: string): void => {
31
+ if (type === 'png') {
32
+ localChart.exportChart({
33
+ type: 'image/png',
34
+ })
35
+ } else if (type === 'jpeg') {
36
+ localChart.exportChart({
37
+ type: 'image/jpeg',
38
+ })
39
+ } else if (type === 'svg') {
40
+ localChart.exportChart({
41
+ type: 'image/svg+xml',
42
+ })
43
+ } else if (type === 'csv') {
44
+ localChart.downloadCSV()
45
+ }
46
+ }
47
+
48
+ const chartOptions = ref<I_LineGraph | I_DiskGraph | null>(null)
49
+ const initGraph = (): void => {
50
+ if (!props.data) return
51
+ setTimeout(() => {
52
+ chartOptions.value = props.data
53
+ }, 500)
54
+ }
55
+
56
+ watch(
57
+ () => props.update,
58
+ (newValue) => {
59
+ newValue && initGraph()
60
+ },
61
+ { immediate: true }
62
+ )
63
+
64
+ watch(
65
+ () => props.exportType,
66
+ (newValue) => {
67
+ if (!newValue) return
68
+
69
+ exportChart(newValue)
70
+ }
71
+ )
72
+
73
+ watch(
74
+ () => props.chart,
75
+ (newValue) => {
76
+ if (newValue.series) localChart = newValue
77
+ },
78
+ { deep: true }
79
+ )
80
+
81
+ const updateSeriesStrokeWidth = (data: number[]): void => {
82
+ if (!localChart) return
83
+
84
+ const newChartOptions = chartOptions.value
85
+ newChartOptions.series.forEach((_: any, key: number) => {
86
+ newChartOptions.series[key].lineWidth = 1.5
87
+
88
+ if (data.includes(key)) newChartOptions.series[key].lineWidth = 3
89
+ })
90
+
91
+ chartOptions.value = newChartOptions
92
+ }
93
+
94
+ watch(
95
+ () => props.selectedRow,
96
+ (newValue) => newValue && updateSeriesStrokeWidth(newValue)
97
+ )
98
+ </script>
99
+
100
+ <style scoped lang="scss">
101
+ .graph-content {
102
+ width: 100%;
103
+ //height: inherit;
104
+ height: 100%;
105
+
106
+ .graph-block {
107
+ height: 100%;
108
+ }
109
+ }
110
+ </style>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bfg-common",
3
3
  "private": false,
4
- "version": "1.4.37",
4
+ "version": "1.4.38",
5
5
  "scripts": {
6
6
  "build": "nuxt build",
7
7
  "dev": "nuxt dev --port=3002",