@kws3/ui 1.4.5 → 1.5.1
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/charts/Chart.svelte +122 -0
- package/charts/DonutChart.svelte +75 -0
- package/charts/MixedChart.svelte +185 -0
- package/charts/PieChart.svelte +76 -0
- package/charts/utils.js +166 -0
- package/controls/Checkbox.svelte +1 -1
- package/controls/NumberInput.svelte +8 -7
- package/index.js +9 -6
- package/package.json +3 -2
- package/settings.js +11 -0
- package/styles/Chart.scss +36 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@param {object} [options={}] - Chart options, Default: `{}`
|
|
6
|
+
@param {string} [type="bar"] - Chart type, Default: `"bar"`
|
|
7
|
+
@param {array} [series=[]] - Series data, Default: `[]`
|
|
8
|
+
@param {string} [width="100%"] - Chart width, Default: `"100%"`
|
|
9
|
+
@param {string} [height="auto"] - Chart height, Default: `"auto"`
|
|
10
|
+
@param {string} [class=""] - CSS classes for container, Default: `""`
|
|
11
|
+
|
|
12
|
+
-->
|
|
13
|
+
<div class="kws-chart {klass}" bind:this={canvas} />
|
|
14
|
+
|
|
15
|
+
<script>
|
|
16
|
+
import { onMount, createEventDispatcher } from "svelte";
|
|
17
|
+
import ApexCharts from "apexcharts/dist/apexcharts.esm";
|
|
18
|
+
import { merge } from "./utils";
|
|
19
|
+
|
|
20
|
+
const fire = createEventDispatcher();
|
|
21
|
+
let canvas, chart;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Chart options
|
|
25
|
+
*/
|
|
26
|
+
export let options = {},
|
|
27
|
+
/**
|
|
28
|
+
* Chart type
|
|
29
|
+
*/
|
|
30
|
+
type = "bar",
|
|
31
|
+
/**
|
|
32
|
+
* Series data
|
|
33
|
+
*/
|
|
34
|
+
series = [],
|
|
35
|
+
/**
|
|
36
|
+
* Chart width
|
|
37
|
+
*/
|
|
38
|
+
width = "100%",
|
|
39
|
+
/**
|
|
40
|
+
* Chart height
|
|
41
|
+
*/
|
|
42
|
+
height = "auto";
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* CSS classes for container
|
|
46
|
+
*/
|
|
47
|
+
let klass = "";
|
|
48
|
+
export { klass as class };
|
|
49
|
+
|
|
50
|
+
onMount(() => {
|
|
51
|
+
init();
|
|
52
|
+
return () => {
|
|
53
|
+
chart && chart.destroy();
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
$: width, height, type, refresh();
|
|
58
|
+
$: series, seriesChanged();
|
|
59
|
+
$: options, optionsChanged();
|
|
60
|
+
|
|
61
|
+
const patchEvents = (evs) => {
|
|
62
|
+
const events = {};
|
|
63
|
+
if (typeof evs != "undefined") {
|
|
64
|
+
for (var type in evs) {
|
|
65
|
+
events[type] = (a, b, c) => {
|
|
66
|
+
fire(type, [a, b, c]);
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return events;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const init = () => {
|
|
74
|
+
chart && chart.destroy();
|
|
75
|
+
|
|
76
|
+
const newOptions = {
|
|
77
|
+
chart: {
|
|
78
|
+
type,
|
|
79
|
+
height,
|
|
80
|
+
width,
|
|
81
|
+
},
|
|
82
|
+
type,
|
|
83
|
+
series,
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
var events = {};
|
|
87
|
+
|
|
88
|
+
if (typeof options.chart.events != "undefined") {
|
|
89
|
+
events = patchEvents(options.chart.events);
|
|
90
|
+
options.chart.events = {};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const config = merge(options, newOptions);
|
|
94
|
+
|
|
95
|
+
if (canvas) {
|
|
96
|
+
config.chart.events = events;
|
|
97
|
+
chart = new ApexCharts(canvas, config);
|
|
98
|
+
chart.render();
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const refresh = () => {
|
|
103
|
+
chart && chart.destroy();
|
|
104
|
+
init();
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const seriesChanged = () => {
|
|
108
|
+
chart ? chart.updateSeries(series, true) : init();
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const optionsChanged = () => {
|
|
112
|
+
if (chart) {
|
|
113
|
+
if (typeof options.chart.events != "undefined") {
|
|
114
|
+
options.chart.events = patchEvents(options.chart.events);
|
|
115
|
+
}
|
|
116
|
+
chart.updateOptions(options, true);
|
|
117
|
+
} else {
|
|
118
|
+
init();
|
|
119
|
+
}
|
|
120
|
+
chart ? chart.updateOptions(options, true) : init();
|
|
121
|
+
};
|
|
122
|
+
</script>
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@param {object} [options={}] - Chart options, see ApexCharts options for donut charts, Default: `{}`
|
|
6
|
+
@param {array} [labels=[]] - Data labels, Default: `[]`
|
|
7
|
+
@param {array} [data=[]] - Chart data, Default: `[]`
|
|
8
|
+
@param {string} [width="100%"] - Chart width, supports CSS size strings, Default: `"100%"`
|
|
9
|
+
@param {string} [height="auto"] - Chart height, supports CSS size strings, Default: `"auto"`
|
|
10
|
+
@param {array} [colors=null] - Chart colors, can be modified globally in framework settings
|
|
11
|
+
|
|
12
|
+
Send an array of colors to override the default colors, or do not send anything to use the default colors, Default: `null`
|
|
13
|
+
@param {string} [class=""] - CSS classes for container, Default: `""`
|
|
14
|
+
|
|
15
|
+
-->
|
|
16
|
+
<Chart
|
|
17
|
+
class={__class}
|
|
18
|
+
options={_options}
|
|
19
|
+
series={_data}
|
|
20
|
+
type="donut"
|
|
21
|
+
{height}
|
|
22
|
+
{width} />
|
|
23
|
+
|
|
24
|
+
<script>
|
|
25
|
+
import { Chart } from "@kws3/ui";
|
|
26
|
+
import { donutChartOptions, merge } from "./utils";
|
|
27
|
+
import { defaultChartColors } from "../settings";
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Chart options, see ApexCharts options for donut charts
|
|
31
|
+
*/
|
|
32
|
+
export let options = {},
|
|
33
|
+
/**
|
|
34
|
+
* Data labels
|
|
35
|
+
*/
|
|
36
|
+
labels = [],
|
|
37
|
+
/**
|
|
38
|
+
* Chart data
|
|
39
|
+
*/
|
|
40
|
+
data = [],
|
|
41
|
+
/**
|
|
42
|
+
* Chart width, supports CSS size strings
|
|
43
|
+
*/
|
|
44
|
+
width = "100%",
|
|
45
|
+
/**
|
|
46
|
+
* Chart height, supports CSS size strings
|
|
47
|
+
*/
|
|
48
|
+
height = "auto",
|
|
49
|
+
/**
|
|
50
|
+
* Chart colors, can be modified globally in framework settings
|
|
51
|
+
*
|
|
52
|
+
* Send an array of colors to override the default colors, or do not send anything to use the default colors
|
|
53
|
+
* @type {array}
|
|
54
|
+
*/
|
|
55
|
+
colors = null;
|
|
56
|
+
/**
|
|
57
|
+
* CSS classes for container
|
|
58
|
+
*/
|
|
59
|
+
let klass = "";
|
|
60
|
+
export { klass as class };
|
|
61
|
+
|
|
62
|
+
$: __class = "kws-donut-chart " + klass;
|
|
63
|
+
|
|
64
|
+
$: usedColors = colors
|
|
65
|
+
? colors
|
|
66
|
+
: $defaultChartColors
|
|
67
|
+
? $defaultChartColors
|
|
68
|
+
: [];
|
|
69
|
+
|
|
70
|
+
$: _data = data || Array(labels.length || 0).fill(0);
|
|
71
|
+
$: _options = merge(
|
|
72
|
+
donutChartOptions(labels),
|
|
73
|
+
Object.assign({}, { colors: usedColors }, options)
|
|
74
|
+
);
|
|
75
|
+
</script>
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@param {object} [options={}] - Chart options, see ApexCharts options for bar charts, Default: `{}`
|
|
6
|
+
@param {array} [labels=[]] - Data labels, Default: `[]`
|
|
7
|
+
@param {array} [sets=[]] - Data sets, Default: `[]`
|
|
8
|
+
@param {array} [data=[]] - Chart data, Default: `[]`
|
|
9
|
+
@param {boolean} [multiaxis=false] - Whether the chart has multiple axes, Default: `false`
|
|
10
|
+
@param {string} [width="100%"] - Chart width, supports CSS size strings, Default: `"100%"`
|
|
11
|
+
@param {string} [height="auto"] - Chart height, supports CSS size strings, Default: `"auto"`
|
|
12
|
+
@param {array} [colors=null] - Chart colors, can be modified globally in framework settings
|
|
13
|
+
|
|
14
|
+
Send an array of colors to override the default colors, or do not send anything to use the default colors, Default: `null`
|
|
15
|
+
@param {string} [class=""] - CSS classes for container, Default: `""`
|
|
16
|
+
|
|
17
|
+
-->
|
|
18
|
+
<Chart
|
|
19
|
+
class={__class}
|
|
20
|
+
options={_options}
|
|
21
|
+
series={_data}
|
|
22
|
+
type="bar"
|
|
23
|
+
{height}
|
|
24
|
+
{width} />
|
|
25
|
+
|
|
26
|
+
<script>
|
|
27
|
+
import { Chart } from "@kws3/ui";
|
|
28
|
+
import { mixedChartOptions, merge } from "./utils";
|
|
29
|
+
import { defaultChartColors } from "../settings";
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Chart options, see ApexCharts options for bar charts
|
|
33
|
+
*/
|
|
34
|
+
export let options = {},
|
|
35
|
+
/**
|
|
36
|
+
* Data labels
|
|
37
|
+
*/
|
|
38
|
+
labels = [],
|
|
39
|
+
/**
|
|
40
|
+
* Data sets
|
|
41
|
+
*/
|
|
42
|
+
sets = [],
|
|
43
|
+
/**
|
|
44
|
+
* Chart data
|
|
45
|
+
*/
|
|
46
|
+
data = [],
|
|
47
|
+
/**
|
|
48
|
+
* Whether the chart has multiple axes
|
|
49
|
+
*/
|
|
50
|
+
multiaxis = false,
|
|
51
|
+
/**
|
|
52
|
+
* Chart width, supports CSS size strings
|
|
53
|
+
*/
|
|
54
|
+
width = "100%",
|
|
55
|
+
/**
|
|
56
|
+
* Chart height, supports CSS size strings
|
|
57
|
+
*/
|
|
58
|
+
height = "auto",
|
|
59
|
+
/**
|
|
60
|
+
* Chart colors, can be modified globally in framework settings
|
|
61
|
+
*
|
|
62
|
+
* Send an array of colors to override the default colors, or do not send anything to use the default colors
|
|
63
|
+
* @type {array}
|
|
64
|
+
*/
|
|
65
|
+
colors = null;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* CSS classes for container
|
|
69
|
+
*/
|
|
70
|
+
let klass = "";
|
|
71
|
+
export { klass as class };
|
|
72
|
+
|
|
73
|
+
$: __class = "kws-mixed-chart " + klass;
|
|
74
|
+
|
|
75
|
+
let _data = [];
|
|
76
|
+
let yAxis = [];
|
|
77
|
+
|
|
78
|
+
let sparklines = false;
|
|
79
|
+
|
|
80
|
+
$: usedColors = colors
|
|
81
|
+
? colors
|
|
82
|
+
: $defaultChartColors
|
|
83
|
+
? $defaultChartColors
|
|
84
|
+
: [];
|
|
85
|
+
|
|
86
|
+
$: data, sets, normaliseAll();
|
|
87
|
+
$: _options = merge(
|
|
88
|
+
mixedChartOptions(labels, multiaxis ? yAxis : yAxis[0], sparklines),
|
|
89
|
+
Object.assign({}, { colors: usedColors }, options)
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
const normaliseAll = () => {
|
|
93
|
+
if (data.length !== sets.length) {
|
|
94
|
+
throw new Error("Data and sets lengths do not match");
|
|
95
|
+
}
|
|
96
|
+
normaliseSets();
|
|
97
|
+
normaliseData();
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const normaliseSets = () => {
|
|
101
|
+
yAxis = [];
|
|
102
|
+
|
|
103
|
+
let _sets = sets || [],
|
|
104
|
+
oppositeAxisApplied = false,
|
|
105
|
+
mainSeriesName = null,
|
|
106
|
+
oppositeSeriesName = null;
|
|
107
|
+
|
|
108
|
+
_sets.forEach((set, idx) => {
|
|
109
|
+
let __set = {};
|
|
110
|
+
let obj = {
|
|
111
|
+
floating: false,
|
|
112
|
+
opposite: false,
|
|
113
|
+
decimalsInFloat: 0,
|
|
114
|
+
axisBorder: {
|
|
115
|
+
show: true,
|
|
116
|
+
},
|
|
117
|
+
axisTicks: {
|
|
118
|
+
show: true,
|
|
119
|
+
},
|
|
120
|
+
labels: {
|
|
121
|
+
show: true,
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
if (typeof set === "string") {
|
|
125
|
+
__set = Object.assign(obj, {
|
|
126
|
+
name: set,
|
|
127
|
+
type: "column",
|
|
128
|
+
});
|
|
129
|
+
} else {
|
|
130
|
+
__set = Object.assign(obj, { name: "set-" + idx, type: "column" }, set);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
//series names cannot be random,
|
|
134
|
+
//they have to be of one of the sets
|
|
135
|
+
if (!mainSeriesName) {
|
|
136
|
+
mainSeriesName = __set.name;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (__set.opposite) {
|
|
140
|
+
//hide extras axes on the opposite side
|
|
141
|
+
if (!oppositeAxisApplied) {
|
|
142
|
+
oppositeAxisApplied = true;
|
|
143
|
+
if (!oppositeSeriesName) {
|
|
144
|
+
oppositeSeriesName = __set.name;
|
|
145
|
+
}
|
|
146
|
+
} else {
|
|
147
|
+
__set.show = false;
|
|
148
|
+
}
|
|
149
|
+
} else {
|
|
150
|
+
//hide extras axes on the main side
|
|
151
|
+
if (idx > 0) {
|
|
152
|
+
__set.show = false;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (__set.forceDisplay) {
|
|
157
|
+
__set.show = true;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
//set a common series name based on axis..
|
|
161
|
+
//so that scales for each axis are the same
|
|
162
|
+
__set.seriesName = __set.opposite ? oppositeSeriesName : mainSeriesName;
|
|
163
|
+
|
|
164
|
+
yAxis.push(__set);
|
|
165
|
+
});
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const normaliseData = () => {
|
|
169
|
+
_data = [];
|
|
170
|
+
|
|
171
|
+
//ensuring data is an array of arrays
|
|
172
|
+
let sliced_data = (data || []).slice();
|
|
173
|
+
if (!Array.isArray(sliced_data[0])) {
|
|
174
|
+
sliced_data = [sliced_data];
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
sliced_data.forEach((set, idx) => {
|
|
178
|
+
_data.push({
|
|
179
|
+
name: yAxis[idx].name,
|
|
180
|
+
type: yAxis[idx].type,
|
|
181
|
+
data: set,
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
};
|
|
185
|
+
</script>
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@param {object} [options={}] - Chart options, see ApexCharts options for pie charts, Default: `{}`
|
|
6
|
+
@param {array} [labels=[]] - Data labels, Default: `[]`
|
|
7
|
+
@param {array} [data=[]] - Chart data, Default: `[]`
|
|
8
|
+
@param {string} [width="100%"] - Chart width, supports CSS size strings, Default: `"100%"`
|
|
9
|
+
@param {string} [height="auto"] - Chart height, supports CSS size strings, Default: `"auto"`
|
|
10
|
+
@param {array} [colors=null] - Chart colors, can be modified globally in framework settings
|
|
11
|
+
|
|
12
|
+
Send an array of colors to override the default colors, or do not send anything to use the default colors, Default: `null`
|
|
13
|
+
@param {string} [class=""] - CSS classes for container, Default: `""`
|
|
14
|
+
|
|
15
|
+
-->
|
|
16
|
+
<Chart
|
|
17
|
+
class={__class}
|
|
18
|
+
options={_options}
|
|
19
|
+
series={_data}
|
|
20
|
+
type="pie"
|
|
21
|
+
{height}
|
|
22
|
+
{width} />
|
|
23
|
+
|
|
24
|
+
<script>
|
|
25
|
+
import { Chart } from "@kws3/ui";
|
|
26
|
+
import { pieChartOptions, merge } from "./utils";
|
|
27
|
+
import { defaultChartColors } from "../settings";
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Chart options, see ApexCharts options for pie charts
|
|
31
|
+
*/
|
|
32
|
+
export let options = {},
|
|
33
|
+
/**
|
|
34
|
+
* Data labels
|
|
35
|
+
*/
|
|
36
|
+
labels = [],
|
|
37
|
+
/**
|
|
38
|
+
* Chart data
|
|
39
|
+
*/
|
|
40
|
+
data = [],
|
|
41
|
+
/**
|
|
42
|
+
* Chart width, supports CSS size strings
|
|
43
|
+
*/
|
|
44
|
+
width = "100%",
|
|
45
|
+
/**
|
|
46
|
+
* Chart height, supports CSS size strings
|
|
47
|
+
*/
|
|
48
|
+
height = "auto",
|
|
49
|
+
/**
|
|
50
|
+
* Chart colors, can be modified globally in framework settings
|
|
51
|
+
*
|
|
52
|
+
* Send an array of colors to override the default colors, or do not send anything to use the default colors
|
|
53
|
+
* @type {array}
|
|
54
|
+
*/
|
|
55
|
+
colors = null;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* CSS classes for container
|
|
59
|
+
*/
|
|
60
|
+
let klass = "";
|
|
61
|
+
export { klass as class };
|
|
62
|
+
|
|
63
|
+
$: __class = "kws-pie-chart " + klass;
|
|
64
|
+
|
|
65
|
+
$: usedColors = colors
|
|
66
|
+
? colors
|
|
67
|
+
: $defaultChartColors
|
|
68
|
+
? $defaultChartColors
|
|
69
|
+
: [];
|
|
70
|
+
|
|
71
|
+
$: _data = data || Array(labels.length || 0).fill(0);
|
|
72
|
+
$: _options = merge(
|
|
73
|
+
pieChartOptions(labels),
|
|
74
|
+
Object.assign({}, { colors: usedColors }, options)
|
|
75
|
+
);
|
|
76
|
+
</script>
|
package/charts/utils.js
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import ApexCharts from "apexcharts/dist/apexcharts.esm";
|
|
2
|
+
|
|
3
|
+
const themeColors = [
|
|
4
|
+
"#284BED",
|
|
5
|
+
"#ED6134",
|
|
6
|
+
"#1DAFEC",
|
|
7
|
+
"#EDB405",
|
|
8
|
+
"#11EDB7",
|
|
9
|
+
"#77ED11",
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
export const merge = ApexCharts.merge;
|
|
13
|
+
|
|
14
|
+
export function pieChartOptions(labels) {
|
|
15
|
+
return {
|
|
16
|
+
chart: {
|
|
17
|
+
type: "pie",
|
|
18
|
+
dropShadow: {
|
|
19
|
+
enabled: false,
|
|
20
|
+
},
|
|
21
|
+
toolbar: {
|
|
22
|
+
show: false,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
colors: themeColors,
|
|
26
|
+
fill: {
|
|
27
|
+
opacity: 1,
|
|
28
|
+
},
|
|
29
|
+
stroke: {
|
|
30
|
+
width: 0,
|
|
31
|
+
},
|
|
32
|
+
states: {
|
|
33
|
+
active: {
|
|
34
|
+
filter: {
|
|
35
|
+
type: "none",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
dataLabels: {
|
|
40
|
+
enabled: false,
|
|
41
|
+
},
|
|
42
|
+
tooltip: {
|
|
43
|
+
shared: true,
|
|
44
|
+
intersect: false,
|
|
45
|
+
fillSeriesColor: false,
|
|
46
|
+
x: {
|
|
47
|
+
show: true,
|
|
48
|
+
formatter: undefined,
|
|
49
|
+
},
|
|
50
|
+
theme: false,
|
|
51
|
+
},
|
|
52
|
+
labels: labels,
|
|
53
|
+
legend: {
|
|
54
|
+
position: "bottom",
|
|
55
|
+
horizontalAlign: "center",
|
|
56
|
+
labels: {
|
|
57
|
+
useSeriesColors: true,
|
|
58
|
+
},
|
|
59
|
+
markers: {
|
|
60
|
+
size: 3,
|
|
61
|
+
shape: "circle",
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function donutChartOptions(labels) {
|
|
68
|
+
var obj = pieChartOptions(labels);
|
|
69
|
+
obj.chart.type = "donut";
|
|
70
|
+
return obj;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function mixedChartOptions(xAxis, yAxis, is_sparkline) {
|
|
74
|
+
return {
|
|
75
|
+
chart: {
|
|
76
|
+
type: "bar",
|
|
77
|
+
stacked: false,
|
|
78
|
+
dropShadow: {
|
|
79
|
+
enabled: false,
|
|
80
|
+
},
|
|
81
|
+
toolbar: {
|
|
82
|
+
show: false,
|
|
83
|
+
},
|
|
84
|
+
sparkline: {
|
|
85
|
+
enabled: is_sparkline ? true : false,
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
colors: themeColors,
|
|
89
|
+
fill: {
|
|
90
|
+
opacity: 1,
|
|
91
|
+
},
|
|
92
|
+
states: {
|
|
93
|
+
active: {
|
|
94
|
+
filter: {
|
|
95
|
+
type: "none",
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
grid: {
|
|
100
|
+
clipMarkers: false,
|
|
101
|
+
},
|
|
102
|
+
dataLabels: {
|
|
103
|
+
enabled: false,
|
|
104
|
+
},
|
|
105
|
+
markers: {
|
|
106
|
+
size: 1,
|
|
107
|
+
shape: "circle",
|
|
108
|
+
},
|
|
109
|
+
plotOptions: {
|
|
110
|
+
bar: {
|
|
111
|
+
horizontal: false,
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
tooltip: {
|
|
115
|
+
shared: true,
|
|
116
|
+
intersect: false,
|
|
117
|
+
x: {
|
|
118
|
+
show: is_sparkline ? true : false,
|
|
119
|
+
},
|
|
120
|
+
y: [
|
|
121
|
+
{},
|
|
122
|
+
{
|
|
123
|
+
formatter: undefined,
|
|
124
|
+
},
|
|
125
|
+
],
|
|
126
|
+
fixed: {
|
|
127
|
+
enabled: true,
|
|
128
|
+
position: "topLeft",
|
|
129
|
+
offsetY: 10,
|
|
130
|
+
offsetX: 25,
|
|
131
|
+
},
|
|
132
|
+
theme: false,
|
|
133
|
+
},
|
|
134
|
+
xaxis: {
|
|
135
|
+
categories: xAxis,
|
|
136
|
+
axisBorder: {
|
|
137
|
+
show: false,
|
|
138
|
+
},
|
|
139
|
+
axisTicks: {
|
|
140
|
+
show: false,
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
yaxis: yAxis,
|
|
144
|
+
stroke: {
|
|
145
|
+
width: 2,
|
|
146
|
+
curve: "smooth",
|
|
147
|
+
},
|
|
148
|
+
legend: {
|
|
149
|
+
position: "top",
|
|
150
|
+
horizontalAlign: "right",
|
|
151
|
+
fontSize: "10px",
|
|
152
|
+
labels: {
|
|
153
|
+
useSeriesColors: true,
|
|
154
|
+
},
|
|
155
|
+
markers: {
|
|
156
|
+
width: 8,
|
|
157
|
+
height: 8,
|
|
158
|
+
radius: 8,
|
|
159
|
+
},
|
|
160
|
+
itemMargin: {
|
|
161
|
+
horizontal: 5,
|
|
162
|
+
vertical: 10,
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
}
|
package/controls/Checkbox.svelte
CHANGED
|
@@ -34,7 +34,7 @@ Ultimately defaults to `fa`, if family is not set anywhere, Default: `"null"`
|
|
|
34
34
|
class="checkbox kws-checkbox is-{size} is-{color} {klass}"
|
|
35
35
|
{style}>
|
|
36
36
|
<!--Checkbox change event-->
|
|
37
|
-
<input type="checkbox" {disabled} bind:checked on:change />
|
|
37
|
+
<input role="checkbox" type="checkbox" {disabled} bind:checked on:change />
|
|
38
38
|
<span class="kws-checkbox-label" style={label_style}>
|
|
39
39
|
<!-- Used for the Checkbox label--><slot />
|
|
40
40
|
</span>
|
|
@@ -28,6 +28,7 @@ This will be overridden if `min` is higher, or `max` is lower, Default: `0`
|
|
|
28
28
|
<div class="field has-addons">
|
|
29
29
|
<div class="control">
|
|
30
30
|
<button
|
|
31
|
+
role="button"
|
|
31
32
|
type="button"
|
|
32
33
|
class="button is-{size} is-{minus_button_color}"
|
|
33
34
|
style="box-shadow:none;"
|
|
@@ -41,6 +42,7 @@ This will be overridden if `min` is higher, or `max` is lower, Default: `0`
|
|
|
41
42
|
</div>
|
|
42
43
|
<div class="control is-{fullwidth ? 'expanded' : 'narrow'}">
|
|
43
44
|
<input
|
|
45
|
+
data-testid="input"
|
|
44
46
|
class="input has-text-centered is-{size} is-{value < min || value > max
|
|
45
47
|
? 'danger'
|
|
46
48
|
: ''}"
|
|
@@ -56,6 +58,7 @@ This will be overridden if `min` is higher, or `max` is lower, Default: `0`
|
|
|
56
58
|
</div>
|
|
57
59
|
<div class="control">
|
|
58
60
|
<button
|
|
61
|
+
role="button"
|
|
59
62
|
type="button"
|
|
60
63
|
class="button is-{size} is-{plus_button_color}"
|
|
61
64
|
style="box-shadow:none;"
|
|
@@ -159,7 +162,8 @@ This will be overridden if `min` is higher, or `max` is lower, Default: `0`
|
|
|
159
162
|
*/
|
|
160
163
|
plus_button_color = "";
|
|
161
164
|
|
|
162
|
-
let _has_focus = false
|
|
165
|
+
let _has_focus = false,
|
|
166
|
+
_old_value = null;
|
|
163
167
|
|
|
164
168
|
$: value && !_has_focus, validateInput(); // will work like on state changed
|
|
165
169
|
|
|
@@ -180,21 +184,18 @@ This will be overridden if `min` is higher, or `max` is lower, Default: `0`
|
|
|
180
184
|
if (typeof value == "undefined" || value === null) value = min;
|
|
181
185
|
value = Number(value) + i * step;
|
|
182
186
|
if (step % 1 != 0) value = value.toFixed(1);
|
|
183
|
-
/**
|
|
184
|
-
* Triggered when value changes
|
|
185
|
-
*/
|
|
186
|
-
fire("change");
|
|
187
187
|
};
|
|
188
188
|
|
|
189
189
|
function validateInput() {
|
|
190
|
-
|
|
190
|
+
if (_old_value == null) _old_value = value;
|
|
191
191
|
|
|
192
192
|
if (typeof value == "undefined" || value === null) value = min;
|
|
193
193
|
|
|
194
194
|
if (value < min) value = min;
|
|
195
195
|
if (value > max) value = max;
|
|
196
196
|
|
|
197
|
-
if (
|
|
197
|
+
if (_old_value != value) {
|
|
198
|
+
_old_value = value;
|
|
198
199
|
/**
|
|
199
200
|
* Triggered when value changes
|
|
200
201
|
*/
|
package/index.js
CHANGED
|
@@ -2,7 +2,6 @@ export { applySettings } from "./settings";
|
|
|
2
2
|
|
|
3
3
|
export { activateTooltips, tooltip, popover } from "./helpers/Tooltip";
|
|
4
4
|
export { default as Popover } from "./helpers/Popover.svelte";
|
|
5
|
-
|
|
6
5
|
export { default as Icon } from "./helpers/Icon.svelte";
|
|
7
6
|
export { default as Message } from "./helpers/Message.svelte";
|
|
8
7
|
export { default as Modal } from "./helpers/Modal.svelte";
|
|
@@ -11,6 +10,8 @@ export { default as Panel } from "./helpers/Panel.svelte";
|
|
|
11
10
|
export { default as Notification } from "./helpers/Notification.svelte";
|
|
12
11
|
export { default as Loader } from "./helpers/Loader.svelte";
|
|
13
12
|
export { default as ActionSheet } from "./helpers/ActionSheet.svelte";
|
|
13
|
+
export { default as Nl2br } from "./helpers/Nl2br.svelte";
|
|
14
|
+
export { default as ClipboardCopier } from "./helpers/ClipboardCopier.svelte";
|
|
14
15
|
export { alert, confirm, prompt, default as Dialog } from "./helpers/Dialog";
|
|
15
16
|
export {
|
|
16
17
|
Notifications,
|
|
@@ -34,27 +35,29 @@ export { default as Toggle } from "./controls/Toggle.svelte";
|
|
|
34
35
|
export { default as ToggleButtons } from "./controls/ToggleButtons.svelte";
|
|
35
36
|
export { default as ToggleControl } from "./controls/ToggleControl.svelte";
|
|
36
37
|
export { default as RangeSlider } from "./controls/RangeSlider.svelte";
|
|
37
|
-
export { default as Nl2br } from "./helpers/Nl2br.svelte";
|
|
38
38
|
|
|
39
39
|
export { default as Transition } from "./transitions/Transition.svelte";
|
|
40
|
+
|
|
40
41
|
export { default as SlidingPane } from "./sliding-panes/SlidingPane.svelte";
|
|
41
42
|
export { default as SlidingPaneSet } from "./sliding-panes/SlidingPaneSet.svelte";
|
|
43
|
+
|
|
42
44
|
export { default as SearchableSelect } from "./forms/select/SearchableSelect.svelte";
|
|
43
45
|
export { default as MultiSelect } from "./forms/select/MultiSelect.svelte";
|
|
44
46
|
export { default as MaskedInput } from "./forms/MaskedInput.svelte";
|
|
45
|
-
|
|
46
47
|
export { default as Colorpicker } from "./forms/colorpicker/Colorpicker.svelte";
|
|
47
|
-
|
|
48
48
|
export { default as Datepicker } from "./forms/Datepicker.svelte";
|
|
49
49
|
export { default as Timepicker } from "./forms/Timepicker.svelte";
|
|
50
50
|
export { datepicker as DatepickerAction } from "./forms/actions.js";
|
|
51
51
|
export { timepicker as TimepickerAction } from "./forms/actions.js";
|
|
52
|
-
|
|
53
52
|
export { default as PasswordValidator } from "./forms/PasswordValidator/PasswordValidator.svelte";
|
|
54
53
|
|
|
55
|
-
export { default as ClipboardCopier } from "./helpers/ClipboardCopier.svelte";
|
|
56
54
|
export { default as GridView } from "./datagrid/GridView/GridView.svelte";
|
|
57
55
|
export { default as TileView } from "./datagrid/TileView/TileView.svelte";
|
|
58
56
|
export { default as DataSearch } from "./datagrid/DataSearch/DataSearch.svelte";
|
|
59
57
|
export { default as Pagination } from "./datagrid/Pagination/Pagination.svelte";
|
|
60
58
|
export { default as DataSort } from "./datagrid/DataSort/DataSort.svelte";
|
|
59
|
+
|
|
60
|
+
export { default as Chart } from "./charts/Chart.svelte";
|
|
61
|
+
export { default as DonutChart } from "./charts/DonutChart.svelte";
|
|
62
|
+
export { default as PieChart } from "./charts/PieChart.svelte";
|
|
63
|
+
export { default as MixedChart } from "./charts/MixedChart.svelte";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kws3/ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"description": "UI components for use with Svelte v3 applications.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -23,9 +23,10 @@
|
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
+
"apexcharts": "^3.32.0",
|
|
26
27
|
"flatpickr": "^4.5.2",
|
|
27
28
|
"text-mask-core": "^5.1.2",
|
|
28
29
|
"tippy.js": "^6.3.1"
|
|
29
30
|
},
|
|
30
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "affc920010dff752a3f8b3b997fe2e160b8a9e67"
|
|
31
32
|
}
|
package/settings.js
CHANGED
|
@@ -5,6 +5,14 @@ const defaultToastPlacement = writable("bottom");
|
|
|
5
5
|
const defaultSnackbarPlacement = writable("bottom-right");
|
|
6
6
|
const defaultNotificationPlacement = writable("top-right");
|
|
7
7
|
const hasTransitions = writable(true);
|
|
8
|
+
const defaultChartColors = writable([
|
|
9
|
+
"#284BED",
|
|
10
|
+
"#ED6134",
|
|
11
|
+
"#1DAFEC",
|
|
12
|
+
"#EDB405",
|
|
13
|
+
"#11EDB7",
|
|
14
|
+
"#77ED11",
|
|
15
|
+
]);
|
|
8
16
|
|
|
9
17
|
const SETTINGS = {
|
|
10
18
|
defaultIconFamily,
|
|
@@ -12,6 +20,7 @@ const SETTINGS = {
|
|
|
12
20
|
defaultSnackbarPlacement,
|
|
13
21
|
defaultNotificationPlacement,
|
|
14
22
|
hasTransitions,
|
|
23
|
+
defaultChartColors,
|
|
15
24
|
};
|
|
16
25
|
|
|
17
26
|
export {
|
|
@@ -20,6 +29,7 @@ export {
|
|
|
20
29
|
defaultSnackbarPlacement,
|
|
21
30
|
defaultNotificationPlacement,
|
|
22
31
|
hasTransitions,
|
|
32
|
+
defaultChartColors,
|
|
23
33
|
};
|
|
24
34
|
|
|
25
35
|
/**
|
|
@@ -28,6 +38,7 @@ export {
|
|
|
28
38
|
* - `defaultSnackbarPlacement`: `"bottom-right"` - default placement of snackbar notifications
|
|
29
39
|
* - `defaultNotificationPlacement`: `"top-right"` - default placement of floating notifications
|
|
30
40
|
* - `hasTransitions`: `true` - Transitions are applied
|
|
41
|
+
* - `defaultChartColors`: `["#284BED", "#ED6134", "#1DAFEC", "#EDB405", "#11EDB7", "#77ED11"]` - default colors for charts
|
|
31
42
|
*
|
|
32
43
|
* @param {*} object containing all settings
|
|
33
44
|
*/
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
$kws-chart-tooltip-background-color: $scheme-main !default;
|
|
2
|
+
$kws-chart-tooltip-foreground-color: $scheme-invert-ter !default;
|
|
3
|
+
|
|
4
|
+
.kws-chart {
|
|
5
|
+
.apexcharts-tooltip {
|
|
6
|
+
display: flex;
|
|
7
|
+
border: 0;
|
|
8
|
+
background: $kws-chart-tooltip-background-color;
|
|
9
|
+
border-radius: 0;
|
|
10
|
+
.apexcharts-tooltip-title {
|
|
11
|
+
background: $kws-chart-tooltip-background-color;
|
|
12
|
+
color: $kws-chart-tooltip-foreground-color;
|
|
13
|
+
border: none;
|
|
14
|
+
}
|
|
15
|
+
.apexcharts-tooltip-series-group.apexcharts-active,
|
|
16
|
+
.apexcharts-tooltip-series-group:last-child {
|
|
17
|
+
padding-bottom: 0;
|
|
18
|
+
}
|
|
19
|
+
.apexcharts-tooltip-marker {
|
|
20
|
+
width: 7px;
|
|
21
|
+
height: 7px;
|
|
22
|
+
margin-right: 5px;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
.apexcharts-legend-text {
|
|
26
|
+
font-size: 12px !important;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&.kws-mixed-chart {
|
|
30
|
+
.apexcharts-tooltip {
|
|
31
|
+
flex-direction: row;
|
|
32
|
+
box-shadow: none;
|
|
33
|
+
background: transparent;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|