@openremote/or-chart 1.3.0-snapshot.20250117163435 → 1.3.0-snapshot.20250120082100

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openremote/or-chart",
3
- "version": "1.3.0-snapshot.20250117163435",
3
+ "version": "1.3.0-snapshot.20250120082100",
4
4
  "description": "OpenRemote chart",
5
5
  "main": "dist/umd/index.bundle.js",
6
6
  "module": "lib/index.js",
@@ -18,13 +18,13 @@
18
18
  "dependencies": {
19
19
  "@material/data-table": "^9.0.0",
20
20
  "@material/dialog": "^9.0.0",
21
- "@openremote/core": "1.3.0-snapshot.20250117163435",
22
- "@openremote/or-asset-tree": "1.3.0-snapshot.20250117163435",
23
- "@openremote/or-attribute-picker": "1.3.0-snapshot.20250117163435",
24
- "@openremote/or-components": "1.3.0-snapshot.20250117163435",
25
- "@openremote/or-icon": "1.3.0-snapshot.20250117163435",
26
- "@openremote/or-mwc-components": "1.3.0-snapshot.20250117163435",
27
- "@openremote/or-translate": "1.3.0-snapshot.20250117163435",
21
+ "@openremote/core": "1.3.0-snapshot.20250120082100",
22
+ "@openremote/or-asset-tree": "1.3.0-snapshot.20250120082100",
23
+ "@openremote/or-attribute-picker": "1.3.0-snapshot.20250120082100",
24
+ "@openremote/or-components": "1.3.0-snapshot.20250120082100",
25
+ "@openremote/or-icon": "1.3.0-snapshot.20250120082100",
26
+ "@openremote/or-mwc-components": "1.3.0-snapshot.20250120082100",
27
+ "@openremote/or-translate": "1.3.0-snapshot.20250120082100",
28
28
  "chart.js": "^3.6.0",
29
29
  "chartjs-adapter-moment": "^1.0.0",
30
30
  "chartjs-plugin-annotation": "^1.1.0",
@@ -33,7 +33,7 @@
33
33
  "moment": "^2.29.4"
34
34
  },
35
35
  "devDependencies": {
36
- "@openremote/util": "1.3.0-snapshot.20250117163435",
36
+ "@openremote/util": "1.3.0-snapshot.20250120082100",
37
37
  "@types/chart.js": "^2.9.34",
38
38
  "@types/offscreencanvas": "^2019.6.4"
39
39
  },
@@ -1,130 +0,0 @@
1
- import { getWcStorybookHelpers } from "wc-storybook-helpers";
2
- import {OrChart} from "@openremote/or-chart";
3
- import "@openremote/or-chart";
4
- import { html } from 'lit';
5
-
6
- const { events, args, argTypes, template } = getWcStorybookHelpers("or-chart");
7
-
8
- /** @type { import('@storybook/web-components').Meta } */
9
- const meta = {
10
- title: "Playground/or-chart",
11
- component: "or-chart",
12
- args,
13
- argTypes: {
14
- ...argTypes,
15
- datapointQuery: {
16
- control: {
17
- type: "object"
18
- },
19
- description: "Query object to get data"
20
- }
21
- },
22
- parameters: {
23
- actions: {
24
- handles: events
25
- }
26
- }
27
- };
28
-
29
- /** @type { import('@storybook/web-components').StoryObj } */
30
- export const Primary = {
31
- args: {
32
- dataProvider: async () => ([{
33
- data: [
34
- {x: new Date(Date.now() - 60000 * 60).getTime(), y: 5},
35
- {x: new Date(Date.now() - 50000 * 60).getTime(), y: 8},
36
- {x: new Date(Date.now() - 40000 * 60).getTime(), y: 3},
37
- {x: new Date(Date.now() - 30000 * 60).getTime(), y: 4},
38
- {x: new Date(Date.now() - 20000 * 60).getTime(), y: 10},
39
- {x: new Date(Date.now() - 10000 * 60).getTime(), y: 2},
40
- {x: new Date().getTime(), y: 4}
41
- ]
42
- }])
43
- },
44
- loaders: [
45
- async (args) => ({
46
- orChart: await loadOrChart(args.allArgs)
47
- })
48
- ],
49
- parameters: {
50
- docs: {
51
- source: {
52
- code: getExampleCode(),
53
- /*transform: (code: string, storyContext: StoryContext) => {
54
- return code;
55
- }*/
56
- },
57
- story: {
58
- height: "370px"
59
- }
60
- }
61
- },
62
- render: (args, { loaded: { orChart }}) => html`${orChart}`
63
- };
64
-
65
- /* ------------------------------------------------------- */
66
- /* UTILITY FUNCTIONS */
67
- /* ------------------------------------------------------- */
68
-
69
- function getExampleCode() {
70
-
71
- //language=javascript
72
- return `
73
- import "@openremote/or-chart";
74
-
75
- // If using Lit; you can use the dataProvider attribute to manually insert data;
76
- const dataProvider = async () => ([{
77
- data: [
78
- {x: new Date(Date.now() - 10000).getTime(), y: 2},
79
- {x: new Date().getTime(), y: 4}
80
- ]
81
- }])
82
-
83
- // ----
84
- // OR you can insert (already fetched) assets
85
- const assets = [];
86
-
87
- // And, specify what attributes of these assets to include in the chart.
88
- // It uses the 'index within the assets array' and the attribute object.
89
- const assetAttributes = [
90
- [0, {name: "temperature", type: "positiveInteger"}],
91
- [0, {name: "humidity", type: "positiveInteger"}],
92
- [1, {name: "temperature", type: "positiveInteger"}],
93
- [1, {name: "humidity", type: "positiveInteger"}]
94
- ];
95
-
96
- // And use the datapointQuery attribute to specify what asset data to fetch
97
- const datapointQuery = {
98
- type: "lttb", // algorithm to apply
99
- fromTimestamp: new Date(Date.now() - 10000).getTime(),
100
- toTimestamp: new Date().getTime(),
101
- amountOfPoints: 100
102
- }
103
- // -----
104
-
105
- // in your HTML code use this, and inject them like this;
106
- <or-chart dataProvider="{dataProvider}"></or-chart>
107
-
108
-
109
- // (IF NOT USING LIT; you should parse the objects to JSON strings)
110
- // const datapointQueryStr = JSON.stringify(datapointQuery);
111
- // const assetsStr = JSON.stringify(assets);
112
- // const assetAttributesStr = JSON.stringify(assetAttributes);
113
-
114
- // ... and inject the JSON like this
115
- // <or-chart assets="assetsStr" assetAttributes="assetAttributeStr" datapointQuery="datapointQuery" />
116
- `
117
- }
118
-
119
- async function loadOrChart(args) {
120
-
121
- const newArgs = Object.fromEntries(Object.entries(args).filter(([key, value]) => (
122
- value != null && String(value).length > 0
123
- )));
124
-
125
- const orChart = Object.assign(new OrChart(), newArgs);
126
-
127
- return orChart;
128
- }
129
-
130
- export default meta;