@enki-tek/fms-web-components 0.1.25 → 0.1.26
Sign up to get free protection for your applications and to get access to all the features.
- package/components/Charts/Chart.svelte +46 -0
- package/components/Charts/Chart.svelte.d.ts +17 -0
- package/index.d.ts +2 -1
- package/index.js +2 -1
- package/package.json +2 -1
@@ -0,0 +1,46 @@
|
|
1
|
+
<!-- src/MyChart.svelte -->
|
2
|
+
<script>
|
3
|
+
import { Chart, registerables } from 'chart.js';
|
4
|
+
import { onDestroy, onMount } from 'svelte';
|
5
|
+
import { chartOptions, getChartData } from './chartOptions';
|
6
|
+
|
7
|
+
export let data = {};
|
8
|
+
export let label = '';
|
9
|
+
export let width = 200;
|
10
|
+
export let height = 200;
|
11
|
+
export let config = {
|
12
|
+
colorCount: 1
|
13
|
+
};
|
14
|
+
export let type = 'line';
|
15
|
+
|
16
|
+
// Register all necessary components
|
17
|
+
Chart.register(...registerables);
|
18
|
+
|
19
|
+
let chart;
|
20
|
+
let canvas;
|
21
|
+
|
22
|
+
onMount(() => {
|
23
|
+
const ctx = canvas.getContext('2d');
|
24
|
+
chart = new Chart(ctx, {
|
25
|
+
type: type, // Change this to 'bar' for a bar chart
|
26
|
+
data: getChartData({ data, label, config }),
|
27
|
+
options: chartOptions
|
28
|
+
});
|
29
|
+
});
|
30
|
+
|
31
|
+
// Cleanup when component is destroyed
|
32
|
+
onDestroy(() => {
|
33
|
+
if (chart) {
|
34
|
+
chart.destroy();
|
35
|
+
}
|
36
|
+
});
|
37
|
+
</script>
|
38
|
+
|
39
|
+
<canvas bind:this={canvas} {width} {height} />
|
40
|
+
|
41
|
+
<style>
|
42
|
+
canvas {
|
43
|
+
max-width: 100%;
|
44
|
+
height: auto;
|
45
|
+
}
|
46
|
+
</style>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
/** @typedef {typeof __propDef.props} ChartProps */
|
2
|
+
/** @typedef {typeof __propDef.events} ChartEvents */
|
3
|
+
/** @typedef {typeof __propDef.slots} ChartSlots */
|
4
|
+
export default class Chart {
|
5
|
+
constructor();
|
6
|
+
}
|
7
|
+
export type ChartProps = typeof __propDef.props;
|
8
|
+
export type ChartEvents = typeof __propDef.events;
|
9
|
+
export type ChartSlots = typeof __propDef.slots;
|
10
|
+
declare const __propDef: {
|
11
|
+
props: {};
|
12
|
+
events: {
|
13
|
+
[evt: string]: CustomEvent<any>;
|
14
|
+
};
|
15
|
+
slots: {};
|
16
|
+
};
|
17
|
+
export {};
|
package/index.d.ts
CHANGED
@@ -83,5 +83,6 @@ import BadgeCard from './components/WidgetCard/BadgeCard.svelte';
|
|
83
83
|
import AlertFooter from './components/WidgetCard/AlertFooter.svelte';
|
84
84
|
import PlainCard from './components/StatusCard/PlainCard.svelte';
|
85
85
|
import GrayCard from './components/StatusCard/GrayCard.svelte';
|
86
|
-
|
86
|
+
import Chart from './components/Charts/Chart.svelte';
|
87
|
+
export { Accordion, AccordionItem, ActionIcon, ActionIconGroup, Alert, Badge, Brand, Breadcrumb, Button, Card, CardBody, CardFooter, CardIcon, CardiconBody, CardiconSubtitle, CardiconTitle, CardLink, CardSubtitle, CardText, CardTitle, Checkbox, derivedStore, Dropdown, DropdownItem, EnkiCard, EnkiSidebar, EnkiTable, Footer, Header, HeaderItem, Icon, Layout, MainMenuHead, menuTypeStore, Modal, ModalBody, ModalFooter, ModalHeader, NavIcon, NavItem, NavLink, NotFound, Page, Pagination, RadioButton, smallMenuwidth, Switch, Tab, TableBody, TableCell, TableHead, TableHeadCell, TableRow, TextField, Toast, Tooltip, UserAvatar, HeaderDropDownLink, HeaderDropDownLinkItem, HeaderLink, HeaderLinks, Content, MenuGroup, MenuItem, SortableGrid, SideBarMenu, StatusCard, StatusCardBody, StatusCardTitle, StatusCardSubtitle, StateCard, WidgetCard, WidgetCardBody, DoughnutChart, PieChart, BarChart, LineChart, SensorWidgetBody, SensorWidgetTitle, SensorWidgetData, SensorWidgetFooter, BadgeCard, AlertFooter, PlainCard, GrayCard, Chart };
|
87
88
|
export default i18nInit;
|
package/index.js
CHANGED
@@ -84,5 +84,6 @@ import BadgeCard from './components/WidgetCard/BadgeCard.svelte';
|
|
84
84
|
import AlertFooter from './components/WidgetCard/AlertFooter.svelte';
|
85
85
|
import PlainCard from './components/StatusCard/PlainCard.svelte';
|
86
86
|
import GrayCard from './components/StatusCard/GrayCard.svelte';
|
87
|
-
|
87
|
+
import Chart from './components/Charts/Chart.svelte';
|
88
|
+
export { Accordion, AccordionItem, ActionIcon, ActionIconGroup, Alert, Badge, Brand, Breadcrumb, Button, Card, CardBody, CardFooter, CardIcon, CardiconBody, CardiconSubtitle, CardiconTitle, CardLink, CardSubtitle, CardText, CardTitle, Checkbox, derivedStore, Dropdown, DropdownItem, EnkiCard, EnkiSidebar, EnkiTable, Footer, Header, HeaderItem, Icon, Layout, MainMenuHead, menuTypeStore, Modal, ModalBody, ModalFooter, ModalHeader, NavIcon, NavItem, NavLink, NotFound, Page, Pagination, RadioButton, smallMenuwidth, Switch, Tab, TableBody, TableCell, TableHead, TableHeadCell, TableRow, TextField, Toast, Tooltip, UserAvatar, HeaderDropDownLink, HeaderDropDownLinkItem, HeaderLink, HeaderLinks, Content, MenuGroup, MenuItem, SortableGrid, SideBarMenu, StatusCard, StatusCardBody, StatusCardTitle, StatusCardSubtitle, StateCard, WidgetCard, WidgetCardBody, DoughnutChart, PieChart, BarChart, LineChart, SensorWidgetBody, SensorWidgetTitle, SensorWidgetData, SensorWidgetFooter, BadgeCard, AlertFooter, PlainCard, GrayCard, Chart };
|
88
89
|
export default i18nInit;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@enki-tek/fms-web-components",
|
3
|
-
"version": "0.1.
|
3
|
+
"version": "0.1.26",
|
4
4
|
"devDependencies": {
|
5
5
|
"@storybook/addon-essentials": "^7.6.14",
|
6
6
|
"@storybook/addon-interactions": "^7.6.14",
|
@@ -78,6 +78,7 @@
|
|
78
78
|
"./components/CardIcon/CardiconSubtitle.svelte": "./components/CardIcon/CardiconSubtitle.svelte",
|
79
79
|
"./components/CardIcon/CardiconTitle.svelte": "./components/CardIcon/CardiconTitle.svelte",
|
80
80
|
"./components/Charts/Barchart.svelte": "./components/Charts/Barchart.svelte",
|
81
|
+
"./components/Charts/Chart.svelte": "./components/Charts/Chart.svelte",
|
81
82
|
"./components/Charts/DoughnutChart.svelte": "./components/Charts/DoughnutChart.svelte",
|
82
83
|
"./components/Charts/LineChart.svelte": "./components/Charts/LineChart.svelte",
|
83
84
|
"./components/Charts/PieChart.svelte": "./components/Charts/PieChart.svelte",
|