@operato/chart 2.0.0-beta.35 → 7.0.0-rc.10
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/CHANGELOG.md +61 -0
- package/dist/src/chartjs/config-converter.js +6 -1
- package/dist/src/chartjs/config-converter.js.map +1 -1
- package/dist/src/chartjs/ox-chart-js.js +3 -1
- package/dist/src/chartjs/ox-chart-js.js.map +1 -1
- package/dist/src/editors/configurer.d.ts +2 -0
- package/dist/src/editors/configurer.js +7 -1
- package/dist/src/editors/configurer.js.map +1 -1
- package/dist/src/editors/input-chart-abstract.js +17 -0
- package/dist/src/editors/input-chart-abstract.js.map +1 -1
- package/dist/src/editors/input-chart-multi-series-abstract.js +11 -11
- package/dist/src/editors/input-chart-multi-series-abstract.js.map +1 -1
- package/dist/src/editors/ox-input-chart-timeseries.d.ts +7 -0
- package/dist/src/editors/ox-input-chart-timeseries.js +234 -0
- package/dist/src/editors/ox-input-chart-timeseries.js.map +1 -0
- package/dist/src/editors/ox-property-editor-chart.js +18 -29
- package/dist/src/editors/ox-property-editor-chart.js.map +1 -1
- package/dist/src/scichart/ox-scichart.d.ts +1 -1
- package/dist/src/scichart/ox-scichart.js +7 -15
- package/dist/src/scichart/ox-scichart.js.map +1 -1
- package/dist/src/utils/text-formatter.d.ts +1 -0
- package/dist/src/utils/text-formatter.js +78 -0
- package/dist/src/utils/text-formatter.js.map +1 -0
- package/dist/stories/ox-input-chart-bar.stories.js +9 -5
- package/dist/stories/ox-input-chart-bar.stories.js.map +1 -1
- package/dist/stories/ox-input-chart-timeseries.stories.d.ts +25 -0
- package/dist/stories/ox-input-chart-timeseries.stories.js +182 -0
- package/dist/stories/ox-input-chart-timeseries.stories.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/src/chartjs/config-converter.ts +7 -1
- package/src/chartjs/ox-chart-js.ts +3 -1
- package/src/editors/configurer.ts +11 -3
- package/src/editors/input-chart-abstract.ts +17 -0
- package/src/editors/input-chart-multi-series-abstract.ts +11 -11
- package/src/editors/ox-input-chart-timeseries.ts +236 -0
- package/src/editors/ox-property-editor-chart.ts +20 -30
- package/src/scichart/ox-scichart.ts +4 -12
- package/src/types.d.ts +1 -0
- package/src/utils/text-formatter.ts +106 -0
- package/stories/ox-input-chart-bar.stories.ts +9 -5
- package/stories/ox-input-chart-timeseries.stories.ts +196 -0
- package/themes/grist-theme.css +1 -3
- package/translations/en.json +1 -0
- package/translations/ja.json +1 -0
- package/translations/ko.json +1 -0
- package/translations/ms.json +39 -2
- package/translations/zh.json +1 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
export function format(mask, value) {
|
|
2
|
+
if (!mask || isNaN(+value)) {
|
|
3
|
+
return value.toString(); // return as it is.
|
|
4
|
+
}
|
|
5
|
+
let isNegative, result, decimal, group, posLeadZero, posTrailZero, posSeparator, part, szSep, integer,
|
|
6
|
+
// find prefix/suffix
|
|
7
|
+
len = mask.length, start = mask.search(/[0-9\-\+#]/), prefix = start > 0 ? mask.substring(0, start) : '',
|
|
8
|
+
// reverse string: not an ideal method if there are surrogate pairs
|
|
9
|
+
str = mask.split('').reverse().join(''), end = str.search(/[0-9\-\+#]/), offset = len - end, substr = mask.substring(offset, offset + 1), indx = offset + (substr === '.' || substr === ',' ? 1 : 0), suffix = end > 0 ? mask.substring(indx, len) : '', splittedMask, splittedValue, stringValue;
|
|
10
|
+
// mask with prefix & suffix removed
|
|
11
|
+
mask = mask.substring(start, indx);
|
|
12
|
+
// convert any string to number according to formation sign.
|
|
13
|
+
value = mask.charAt(0) === '-' ? -value : +value;
|
|
14
|
+
isNegative = value < 0 ? ((value = -value), true) : false; // process only abs(), and turn on flag.
|
|
15
|
+
// search for separator for grp & decimal, anything not digit, not +/- sign, not #.
|
|
16
|
+
result = mask.match(/[^\d\-\+#]/g);
|
|
17
|
+
decimal = '.'; // ( result && result[ result.length - 1 ] ) || '.'; // ','는 소수점이 되지 않게 함
|
|
18
|
+
group = (result && result[1] && result[0]) || ','; // treat the left most symbol as group separator
|
|
19
|
+
// split the decimal for the format string if any.
|
|
20
|
+
splittedMask = mask.split(decimal);
|
|
21
|
+
// Fix the decimal first, toFixed will auto fill trailing zero.
|
|
22
|
+
value = parseFloat(value.toFixed((splittedMask[1] && splittedMask[1].length) || 0));
|
|
23
|
+
stringValue = +value + ''; // convert number to string to trim off *all* trailing decimal zero(es)
|
|
24
|
+
// fill back any trailing zero according to format
|
|
25
|
+
posTrailZero = (splittedMask[1] && splittedMask[1].lastIndexOf('0')) || 0; // look for last zero in format
|
|
26
|
+
part = stringValue.split('.');
|
|
27
|
+
// integer will get !part[1]
|
|
28
|
+
if (!part[1] || (part[1] && part[1].length <= posTrailZero)) {
|
|
29
|
+
stringValue = (+value).toFixed(posTrailZero + 1);
|
|
30
|
+
}
|
|
31
|
+
szSep = splittedMask[0].split(group); // look for separator
|
|
32
|
+
splittedMask[0] = szSep.join(''); // join back without separator for counting the pos of any leading 0.
|
|
33
|
+
posLeadZero = (splittedMask[0] && splittedMask[0].indexOf('0')) || 0;
|
|
34
|
+
if (posLeadZero > -1) {
|
|
35
|
+
while (part[0].length < splittedMask[0].length - posLeadZero) {
|
|
36
|
+
part[0] = '0' + part[0];
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
else if (+part[0] === 0) {
|
|
40
|
+
part[0] = '';
|
|
41
|
+
}
|
|
42
|
+
splittedValue = stringValue.split('.');
|
|
43
|
+
splittedValue[0] = part[0];
|
|
44
|
+
// process the first group separator from decimal (.) only, the rest ignore.
|
|
45
|
+
// get the length of the last slice of split result.
|
|
46
|
+
posSeparator = (szSep[1] && szSep[szSep.length - 1].length) || 0;
|
|
47
|
+
if (posSeparator) {
|
|
48
|
+
integer = splittedValue[0];
|
|
49
|
+
str = '';
|
|
50
|
+
offset = integer.length % posSeparator;
|
|
51
|
+
len = integer.length;
|
|
52
|
+
for (indx = 0; indx < len; indx++) {
|
|
53
|
+
str += integer.charAt(indx); // ie6 only support charAt for sz.
|
|
54
|
+
// -posSeparator so that won't trail separator on full length
|
|
55
|
+
/* jshint -W018 */
|
|
56
|
+
if (!((indx - offset + 1) % posSeparator) && indx < len - posSeparator) {
|
|
57
|
+
str += group;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
splittedValue[0] = str;
|
|
61
|
+
}
|
|
62
|
+
splittedValue[1] = splittedMask[1] && splittedValue[1] ? decimal + splittedValue[1] : '';
|
|
63
|
+
// remove negative sign if result is zero
|
|
64
|
+
result = splittedValue.join('');
|
|
65
|
+
if (result === '0' || result === '') {
|
|
66
|
+
// remove negative sign if result is zero
|
|
67
|
+
isNegative = false;
|
|
68
|
+
}
|
|
69
|
+
// 앞에 +가 붙는다면 양수일 경우에도 +를 표기해줌
|
|
70
|
+
let fixedPlusSign;
|
|
71
|
+
if (splittedMask[0].substring(0, 1) === '+')
|
|
72
|
+
fixedPlusSign = isNegative ? '-' : '+';
|
|
73
|
+
else
|
|
74
|
+
fixedPlusSign = isNegative ? '-' : '';
|
|
75
|
+
// put back any negation, combine integer and fraction, and add back prefix & suffix
|
|
76
|
+
return prefix + (fixedPlusSign + result) + suffix;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=text-formatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-formatter.js","sourceRoot":"","sources":["../../../src/utils/text-formatter.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,MAAM,CAAC,IAAY,EAAE,KAAa;IAChD,IAAI,CAAC,IAAI,IAAI,KAAK,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAA,CAAC,mBAAmB;IAC7C,CAAC;IAED,IAAI,UAAmB,EACrB,MAAwC,EACxC,OAAe,EACf,KAAa,EACb,WAAmB,EACnB,YAAoB,EACpB,YAAoB,EACpB,IAAc,EACd,KAAe,EACf,OAAe;IACf,qBAAqB;IACrB,GAAG,G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AG,CAAC,CAAC,GAAG,YAAY,CAAC,IAAI,IAAI,GAAG,GAAG,GAAG,YAAY,EAAE,CAAC;gBACvE,GAAG,IAAI,KAAK,CAAA;YACd,CAAC;QACH,CAAC;QACD,aAAa,CAAC,CAAC,CAAC,GAAG,GAAG,CAAA;IACxB,CAAC;IACD,aAAa,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IAExF,yCAAyC;IACzC,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAC/B,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,EAAE,EAAE,CAAC;QACpC,yCAAyC;QACzC,UAAU,GAAG,KAAK,CAAA;IACpB,CAAC;IAED,8BAA8B;IAC9B,IAAI,aAAqB,CAAA;IAEzB,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,GAAG;QAAE,aAAa,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAA;;QAC9E,aAAa,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAA;IAE1C,oFAAoF;IACpF,OAAO,MAAM,GAAG,CAAC,aAAa,GAAG,MAAM,CAAC,GAAG,MAAM,CAAA;AACnD,CAAC","sourcesContent":["export function format(mask: string, value: number): string {\n if (!mask || isNaN(+value)) {\n return value.toString() // return as it is.\n }\n\n let isNegative: boolean,\n result: string | RegExpMatchArray | null,\n decimal: string,\n group: string,\n posLeadZero: number,\n posTrailZero: number,\n posSeparator: number,\n part: string[],\n szSep: string[],\n integer: string,\n // find prefix/suffix\n len = mask.length,\n start = mask.search(/[0-9\\-\\+#]/),\n prefix = start > 0 ? mask.substring(0, start) : '',\n // reverse string: not an ideal method if there are surrogate pairs\n str = mask.split('').reverse().join(''),\n end = str.search(/[0-9\\-\\+#]/),\n offset = len - end,\n substr = mask.substring(offset, offset + 1),\n indx = offset + (substr === '.' || substr === ',' ? 1 : 0),\n suffix = end > 0 ? mask.substring(indx, len) : '',\n splittedMask: string[],\n splittedValue: string[],\n stringValue: string\n\n // mask with prefix & suffix removed\n mask = mask.substring(start, indx)\n\n // convert any string to number according to formation sign.\n value = mask.charAt(0) === '-' ? -value : +value\n isNegative = value < 0 ? ((value = -value), true) : false // process only abs(), and turn on flag.\n\n // search for separator for grp & decimal, anything not digit, not +/- sign, not #.\n result = mask.match(/[^\\d\\-\\+#]/g)\n decimal = '.' // ( result && result[ result.length - 1 ] ) || '.'; // ','는 소수점이 되지 않게 함\n group = (result && result[1] && result[0]) || ',' // treat the left most symbol as group separator\n\n // split the decimal for the format string if any.\n splittedMask = mask.split(decimal)\n // Fix the decimal first, toFixed will auto fill trailing zero.\n value = parseFloat(value.toFixed((splittedMask[1] && splittedMask[1].length) || 0))\n stringValue = +value + '' // convert number to string to trim off *all* trailing decimal zero(es)\n\n // fill back any trailing zero according to format\n posTrailZero = (splittedMask[1] && splittedMask[1].lastIndexOf('0')) || 0 // look for last zero in format\n part = stringValue.split('.')\n // integer will get !part[1]\n if (!part[1] || (part[1] && part[1].length <= posTrailZero)) {\n stringValue = (+value).toFixed(posTrailZero + 1)\n }\n szSep = splittedMask[0].split(group) // look for separator\n splittedMask[0] = szSep.join('') // join back without separator for counting the pos of any leading 0.\n\n posLeadZero = (splittedMask[0] && splittedMask[0].indexOf('0')) || 0\n if (posLeadZero > -1) {\n while (part[0].length < splittedMask[0].length - posLeadZero) {\n part[0] = '0' + part[0]\n }\n } else if (+part[0] === 0) {\n part[0] = ''\n }\n\n splittedValue = stringValue.split('.')\n splittedValue[0] = part[0]\n\n // process the first group separator from decimal (.) only, the rest ignore.\n // get the length of the last slice of split result.\n posSeparator = (szSep[1] && szSep[szSep.length - 1].length) || 0\n if (posSeparator) {\n integer = splittedValue[0]\n str = ''\n offset = integer.length % posSeparator\n len = integer.length\n for (indx = 0; indx < len; indx++) {\n str += integer.charAt(indx) // ie6 only support charAt for sz.\n // -posSeparator so that won't trail separator on full length\n /* jshint -W018 */\n if (!((indx - offset + 1) % posSeparator) && indx < len - posSeparator) {\n str += group\n }\n }\n splittedValue[0] = str\n }\n splittedValue[1] = splittedMask[1] && splittedValue[1] ? decimal + splittedValue[1] : ''\n\n // remove negative sign if result is zero\n result = splittedValue.join('')\n if (result === '0' || result === '') {\n // remove negative sign if result is zero\n isNegative = false\n }\n\n // 앞에 +가 붙는다면 양수일 경우에도 +를 표기해줌\n let fixedPlusSign: string\n\n if (splittedMask[0].substring(0, 1) === '+') fixedPlusSign = isNegative ? '-' : '+'\n else fixedPlusSign = isNegative ? '-' : ''\n\n // put back any negation, combine integer and fraction, and add back prefix & suffix\n return prefix + (fixedPlusSign + result) + suffix\n}\n"]}
|
|
@@ -107,7 +107,11 @@ const Template = ({ value }) => html `
|
|
|
107
107
|
</div>
|
|
108
108
|
`;
|
|
109
109
|
export const Default = Template.bind({});
|
|
110
|
-
Default.args = {
|
|
110
|
+
Default.args = {
|
|
111
|
+
value: {
|
|
112
|
+
...getDefaultChartConfig('bar')
|
|
113
|
+
}
|
|
114
|
+
};
|
|
111
115
|
export const WithData = Template.bind({});
|
|
112
116
|
WithData.args = {
|
|
113
117
|
value: {
|
|
@@ -117,7 +121,7 @@ WithData.args = {
|
|
|
117
121
|
{
|
|
118
122
|
label: 'Bar Series',
|
|
119
123
|
type: 'bar',
|
|
120
|
-
data: [10, 20, 30],
|
|
124
|
+
// data: [10, 20, 30],
|
|
121
125
|
backgroundColor: 'rgba(255, 99, 132, 0.2)',
|
|
122
126
|
borderColor: 'rgba(255, 99, 132, 1)',
|
|
123
127
|
borderWidth: 1
|
|
@@ -125,7 +129,7 @@ WithData.args = {
|
|
|
125
129
|
{
|
|
126
130
|
label: 'Line Series',
|
|
127
131
|
type: 'line',
|
|
128
|
-
data: [15, 25, 35],
|
|
132
|
+
// data: [15, 25, 35],
|
|
129
133
|
borderColor: 'rgba(54, 162, 235, 1)',
|
|
130
134
|
borderWidth: 1,
|
|
131
135
|
fill: false,
|
|
@@ -158,7 +162,7 @@ MultiAxis.args = {
|
|
|
158
162
|
{
|
|
159
163
|
label: 'Bar Series',
|
|
160
164
|
type: 'bar',
|
|
161
|
-
data: [10, 20, 30],
|
|
165
|
+
// data: [10, 20, 30],
|
|
162
166
|
backgroundColor: 'rgba(255, 99, 132, 0.2)',
|
|
163
167
|
borderColor: 'rgba(255, 99, 132, 1)',
|
|
164
168
|
borderWidth: 1,
|
|
@@ -167,7 +171,7 @@ MultiAxis.args = {
|
|
|
167
171
|
{
|
|
168
172
|
label: 'Line Series',
|
|
169
173
|
type: 'line',
|
|
170
|
-
data: [15, 25, 35],
|
|
174
|
+
// data: [15, 25, 35],
|
|
171
175
|
borderColor: 'rgba(54, 162, 235, 1)',
|
|
172
176
|
borderWidth: 1,
|
|
173
177
|
fill: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ox-input-chart-bar.stories.js","sourceRoot":"","sources":["../../stories/ox-input-chart-bar.stories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAA;AAE1C,OAAO,wCAAwC,CAAA;AAC/C,OAAO,+BAA+B,CAAA;AACtC,OAAO,gCAAgC,CAAA;AAEvC,OAAO,EAAE,IAAI,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAEzD,eAAe;IACb,KAAK,EAAE,8BAA8B;IACrC,SAAS,EAAE,sBAAsB;IACjC,QAAQ,EAAE;QACR,KAAK,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE;KAC7B;CACF,CAAA;AAYD,MAAM,QAAQ,GAAoB,CAAC,EAAE,KAAK,EAAY,EAAE,EAAE,CAAC,IAAI,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAW,EAAE,IAAI,EAAE,EAAE,CAAC;gBACzC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,CAAC;aAC1C;YACD,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;SAC1B;KACF;CACF,CAAA;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AAC1C,SAAS,CAAC,IAAI,GAAG;IACf,KAAK,EAAE;QACL,GAAG,qBAAqB,CAAC,KAAK,CAAC;QAC/B,OAAO,EAAE;YACP,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC,OAAO;YACvC,SAAS,EAAE,IAAI;SAChB;QACD,IAAI,EAAE;YACJ,QAAQ,EAAE;gBACR;oBACE,KAAK,EAAE,YAAY;oBACnB,IAAI,EAAE,KAAK;oBACX,sBAAsB;oBACtB,eAAe,EAAE,yBAAyB;oBAC1C,WAAW,EAAE,uBAAuB;oBACpC,WAAW,EAAE,CAAC;oBACd,OAAO,EAAE,MAAM;iBAChB;gBACD;oBACE,KAAK,EAAE,aAAa;oBACpB,IAAI,EAAE,MAAM;oBACZ,sBAAsB;oBACtB,WAAW,EAAE,uBAAuB;oBACpC,WAAW,EAAE,CAAC;oBACd,IAAI,EAAE,KAAK;oBACX,WAAW,EAAE,GAAG;oBAChB,UAAU,EAAE,QAAQ;oBACpB,WAAW,EAAE,CAAC;oBACd,OAAO,EAAE,OAAO;iBACjB;aACF;YACD,YAAY,EAAE,QAAQ;SACvB;KACF;CACF,CAAA","sourcesContent":["import { html, TemplateResult } from 'lit'\n\nimport '../src/editors/ox-input-chart-mixed.js'\nimport '../src/chartjs/ox-chart-js.js'\nimport '../src/scichart/ox-scichart.js'\n\nimport { data, getDefaultChartConfig } from './common.js'\n\nexport default {\n title: 'ox-input-chart-mixed for bar',\n component: 'ox-input-chart-mixed',\n argTypes: {\n value: { control: 'object' }\n }\n}\n\ninterface Story<T> {\n (args: T): TemplateResult\n args?: Partial<T>\n argTypes?: Record<string, unknown>\n}\n\ninterface ArgTypes {\n value: OperatoChart.ChartConfig\n}\n\nconst Template: Story<ArgTypes> = ({ value }: ArgTypes) => html`\n <link\n href=\"https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL@20..48,100..700,0..1\"\n rel=\"stylesheet\"\n />\n <link\n href=\"https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL@20..48,100..700,0..1\"\n rel=\"stylesheet\"\n />\n <link\n href=\"https://fonts.googleapis.com/css2?family=Material+Symbols+Sharp:opsz,wght,FILL@20..48,100..700,0..1\"\n rel=\"stylesheet\"\n />\n\n <link href=\"/themes/light.css\" rel=\"stylesheet\" />\n <link href=\"/themes/dark.css\" rel=\"stylesheet\" />\n <link href=\"/themes/spacing.css\" rel=\"stylesheet\" />\n\n <style>\n .container {\n width: 100%;\n height: 100%;\n\n display: flex;\n flex-direction: row;\n overflow-y: auto;\n padding: var(--spacing-medium);\n }\n\n .container.dark {\n background-color: black;\n }\n\n #editor {\n width: 300px;\n }\n\n #charts {\n flex: 1;\n\n display: flex;\n flex-direction: column;\n padding: 10px;\n }\n\n #chartjs {\n flex: 1;\n }\n\n #scichart {\n flex: 1;\n }\n </style>\n\n <div style=\"background-color: black; color: white;\">\n Type 'count' or 'average' for series dataKey, type 'year' for axis's dataKey\n </div>\n\n <div class=\"container light\">\n <ox-input-chart-mixed\n chart-type=\"bar\"\n id=\"editor\"\n .value=${value}\n @change=${(e: CustomEvent) => {\n const target = e.currentTarget as any\n const config = target.value\n const chartjs = document.querySelector('#chartjs') as HTMLElement\n if (chartjs) {\n ;(chartjs as any).config = { ...config }\n }\n const scichart = document.querySelector('#scichart') as HTMLElement\n if (scichart) {\n ;(scichart as any).config = config\n }\n\n const container = document.querySelector('.container') as HTMLElement\n if (container) {\n const theme = config.options.theme\n if (theme == 'dark') {\n container.classList.remove('light')\n container.classList.add('dark')\n } else {\n container.classList.remove('dark')\n container.classList.add('light')\n }\n }\n }}\n ></ox-input-chart-mixed>\n <div id=\"charts\">\n <ox-chart-js id=\"chartjs\" .data=${data}></ox-chart-js>\n <ox-scichart id=\"scichart\"></ox-scichart>\n </div>\n </div>\n`\n\nexport const Default = Template.bind({})\nDefault.args = {\n value: {\n ...getDefaultChartConfig('bar')\n }\n}\n\nexport const WithData = Template.bind({})\nWithData.args = {\n value: {\n ...getDefaultChartConfig('bar'),\n data: {\n datasets: [\n {\n label: 'Bar Series',\n type: 'bar',\n // data: [10, 20, 30],\n backgroundColor: 'rgba(255, 99, 132, 0.2)',\n borderColor: 'rgba(255, 99, 132, 1)',\n borderWidth: 1\n },\n {\n label: 'Line Series',\n type: 'line',\n // data: [15, 25, 35],\n borderColor: 'rgba(54, 162, 235, 1)',\n borderWidth: 1,\n fill: false,\n lineTension: 0.4,\n pointStyle: 'circle',\n pointRadius: 3\n }\n ],\n labelDataKey: 'labels'\n },\n options: {\n scales: {\n xAxes: [{ ticks: { beginAtZero: true } }],\n yAxes: [{ ticks: { beginAtZero: true } }]\n },\n legend: { display: true }\n }\n }\n}\n\nexport const MultiAxis = Template.bind({})\nMultiAxis.args = {\n value: {\n ...getDefaultChartConfig('bar'),\n options: {\n ...getDefaultChartConfig('bar').options,\n multiAxis: true\n },\n data: {\n datasets: [\n {\n label: 'Bar Series',\n type: 'bar',\n // data: [10, 20, 30],\n backgroundColor: 'rgba(255, 99, 132, 0.2)',\n borderColor: 'rgba(255, 99, 132, 1)',\n borderWidth: 1,\n yAxisID: 'left'\n },\n {\n label: 'Line Series',\n type: 'line',\n // data: [15, 25, 35],\n borderColor: 'rgba(54, 162, 235, 1)',\n borderWidth: 1,\n fill: false,\n lineTension: 0.4,\n pointStyle: 'circle',\n pointRadius: 3,\n yAxisID: 'right'\n }\n ],\n labelDataKey: 'labels'\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { TemplateResult } from 'lit';
|
|
2
|
+
import '../src/editors/ox-input-chart-timeseries.js';
|
|
3
|
+
import '../src/chartjs/ox-chart-js.js';
|
|
4
|
+
import '../src/scichart/ox-scichart.js';
|
|
5
|
+
declare const _default: {
|
|
6
|
+
title: string;
|
|
7
|
+
component: string;
|
|
8
|
+
argTypes: {
|
|
9
|
+
value: {
|
|
10
|
+
control: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export default _default;
|
|
15
|
+
interface Story<T> {
|
|
16
|
+
(args: T): TemplateResult;
|
|
17
|
+
args?: Partial<T>;
|
|
18
|
+
argTypes?: Record<string, unknown>;
|
|
19
|
+
}
|
|
20
|
+
interface ArgTypes {
|
|
21
|
+
value: OperatoChart.ChartConfig;
|
|
22
|
+
}
|
|
23
|
+
export declare const Default: Story<ArgTypes>;
|
|
24
|
+
export declare const WithData: Story<ArgTypes>;
|
|
25
|
+
export declare const MultiAxis: Story<ArgTypes>;
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
import '../src/editors/ox-input-chart-timeseries.js';
|
|
3
|
+
import '../src/chartjs/ox-chart-js.js';
|
|
4
|
+
import '../src/scichart/ox-scichart.js';
|
|
5
|
+
import { data, getDefaultChartConfig } from './common.js';
|
|
6
|
+
export default {
|
|
7
|
+
title: 'ox-input-chart-timeseries',
|
|
8
|
+
component: 'ox-input-chart-timeseries',
|
|
9
|
+
argTypes: {
|
|
10
|
+
value: { control: 'object' }
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
const Template = ({ value }) => html `
|
|
14
|
+
<link
|
|
15
|
+
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL@20..48,100..700,0..1"
|
|
16
|
+
rel="stylesheet"
|
|
17
|
+
/>
|
|
18
|
+
<link
|
|
19
|
+
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL@20..48,100..700,0..1"
|
|
20
|
+
rel="stylesheet"
|
|
21
|
+
/>
|
|
22
|
+
<link
|
|
23
|
+
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Sharp:opsz,wght,FILL@20..48,100..700,0..1"
|
|
24
|
+
rel="stylesheet"
|
|
25
|
+
/>
|
|
26
|
+
|
|
27
|
+
<link href="/themes/light.css" rel="stylesheet" />
|
|
28
|
+
<link href="/themes/dark.css" rel="stylesheet" />
|
|
29
|
+
<link href="/themes/spacing.css" rel="stylesheet" />
|
|
30
|
+
|
|
31
|
+
<style>
|
|
32
|
+
.container {
|
|
33
|
+
width: 100%;
|
|
34
|
+
height: 100%;
|
|
35
|
+
|
|
36
|
+
display: flex;
|
|
37
|
+
flex-direction: row;
|
|
38
|
+
overflow-y: auto;
|
|
39
|
+
padding: var(--spacing-medium);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.container.dark {
|
|
43
|
+
background-color: black;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
#editor {
|
|
47
|
+
width: 300px;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
#charts {
|
|
51
|
+
flex: 1;
|
|
52
|
+
|
|
53
|
+
display: flex;
|
|
54
|
+
flex-direction: column;
|
|
55
|
+
padding: 10px;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
#chartjs {
|
|
59
|
+
flex: 1;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
#scichart {
|
|
63
|
+
flex: 1;
|
|
64
|
+
}
|
|
65
|
+
</style>
|
|
66
|
+
|
|
67
|
+
<div style="background-color: black; color: white;">
|
|
68
|
+
Type 'count' or 'average' for series dataKey, type 'year' for axis's dataKey
|
|
69
|
+
</div>
|
|
70
|
+
|
|
71
|
+
<div class="container light">
|
|
72
|
+
<ox-input-chart-timeseries
|
|
73
|
+
chart-type="line"
|
|
74
|
+
id="editor"
|
|
75
|
+
.value=${value}
|
|
76
|
+
@change=${(e) => {
|
|
77
|
+
const target = e.currentTarget;
|
|
78
|
+
const config = target.value;
|
|
79
|
+
const chartjs = document.querySelector('#chartjs');
|
|
80
|
+
if (chartjs) {
|
|
81
|
+
;
|
|
82
|
+
chartjs.config = { ...config };
|
|
83
|
+
}
|
|
84
|
+
const scichart = document.querySelector('#scichart');
|
|
85
|
+
if (scichart) {
|
|
86
|
+
;
|
|
87
|
+
scichart.config = config;
|
|
88
|
+
}
|
|
89
|
+
const container = document.querySelector('.container');
|
|
90
|
+
if (container) {
|
|
91
|
+
const theme = config.options.theme;
|
|
92
|
+
if (theme == 'dark') {
|
|
93
|
+
container.classList.remove('light');
|
|
94
|
+
container.classList.add('dark');
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
container.classList.remove('dark');
|
|
98
|
+
container.classList.add('light');
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}}
|
|
102
|
+
></ox-input-chart-timeseries>
|
|
103
|
+
<div id="charts">
|
|
104
|
+
<ox-scichart id="scichart" .data=${data} attr-x="year" attr-y="count"></ox-scichart>
|
|
105
|
+
<ox-chart-js id="chartjs" .data=${data}></ox-chart-js>
|
|
106
|
+
</div>
|
|
107
|
+
</div>
|
|
108
|
+
`;
|
|
109
|
+
export const Default = Template.bind({});
|
|
110
|
+
Default.args = {};
|
|
111
|
+
export const WithData = Template.bind({});
|
|
112
|
+
WithData.args = {
|
|
113
|
+
value: {
|
|
114
|
+
...getDefaultChartConfig('line'),
|
|
115
|
+
data: {
|
|
116
|
+
datasets: [
|
|
117
|
+
{
|
|
118
|
+
dataKey: 'count',
|
|
119
|
+
label: 'Line Series count',
|
|
120
|
+
type: 'line',
|
|
121
|
+
backgroundColor: 'rgba(255, 99, 132, 0.2)',
|
|
122
|
+
borderColor: 'rgba(255, 99, 132, 1)',
|
|
123
|
+
borderWidth: 1
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
dataKey: 'average',
|
|
127
|
+
label: 'Line Series average',
|
|
128
|
+
type: 'line',
|
|
129
|
+
borderColor: 'rgba(54, 162, 235, 1)',
|
|
130
|
+
borderWidth: 1,
|
|
131
|
+
fill: false,
|
|
132
|
+
lineTension: 0.4,
|
|
133
|
+
pointStyle: 'circle',
|
|
134
|
+
pointRadius: 3
|
|
135
|
+
}
|
|
136
|
+
],
|
|
137
|
+
labelDataKey: 'year'
|
|
138
|
+
},
|
|
139
|
+
options: {
|
|
140
|
+
scales: {
|
|
141
|
+
xAxes: [{ ticks: { beginAtZero: true } }],
|
|
142
|
+
yAxes: [{ ticks: { beginAtZero: true } }]
|
|
143
|
+
},
|
|
144
|
+
legend: { display: true }
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
export const MultiAxis = Template.bind({});
|
|
149
|
+
MultiAxis.args = {
|
|
150
|
+
value: {
|
|
151
|
+
...getDefaultChartConfig('line'),
|
|
152
|
+
options: {
|
|
153
|
+
...getDefaultChartConfig('line').options,
|
|
154
|
+
multiAxis: true
|
|
155
|
+
},
|
|
156
|
+
data: {
|
|
157
|
+
datasets: [
|
|
158
|
+
{
|
|
159
|
+
label: 'Bar Series',
|
|
160
|
+
type: 'bar',
|
|
161
|
+
backgroundColor: 'rgba(255, 99, 132, 0.2)',
|
|
162
|
+
borderColor: 'rgba(255, 99, 132, 1)',
|
|
163
|
+
borderWidth: 1,
|
|
164
|
+
yAxisID: 'left'
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
label: 'Line Series',
|
|
168
|
+
type: 'line',
|
|
169
|
+
borderColor: 'rgba(54, 162, 235, 1)',
|
|
170
|
+
borderWidth: 1,
|
|
171
|
+
fill: false,
|
|
172
|
+
lineTension: 0.4,
|
|
173
|
+
pointStyle: 'circle',
|
|
174
|
+
pointRadius: 3,
|
|
175
|
+
yAxisID: 'right'
|
|
176
|
+
}
|
|
177
|
+
],
|
|
178
|
+
labelDataKey: 'labels'
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
//# sourceMappingURL=ox-input-chart-timeseries.stories.js.map
|
|
@@ -0,0 +1 @@
|
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CAAC,EAAE,KAAK,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,CAAC;gBACzC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,CAAC;aAC1C;YACD,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;SAC1B;KACF;CACF,CAAA;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AAC1C,SAAS,CAAC,IAAI,GAAG;IACf,KAAK,EAAE;QACL,GAAG,qBAAqB,CAAC,MAAM,CAAC;QAChC,OAAO,EAAE;YACP,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC,OAAO;YACxC,SAAS,EAAE,IAAI;SAChB;QACD,IAAI,EAAE;YACJ,QAAQ,EAAE;gBACR;oBACE,KAAK,EAAE,YAAY;oBACnB,IAAI,EAAE,KAAK;oBACX,eAAe,EAAE,yBAAyB;oBAC1C,WAAW,EAAE,uBAAuB;oBACpC,WAAW,EAAE,CAAC;oBACd,OAAO,EAAE,MAAM;iBAChB;gBACD;oBACE,KAAK,EAAE,aAAa;oBACpB,IAAI,EAAE,MAAM;oBACZ,WAAW,EAAE,uBAAuB;oBACpC,WAAW,EAAE,CAAC;oBACd,IAAI,EAAE,KAAK;oBACX,WAAW,EAAE,GAAG;oBAChB,UAAU,EAAE,QAAQ;oBACpB,WAAW,EAAE,CAAC;oBACd,OAAO,EAAE,OAAO;iBACjB;aACF;YACD,YAAY,EAAE,QAAQ;SACvB;KACF;CACF,CAAA","sourcesContent":["import { html, TemplateResult } from 'lit'\n\nimport '../src/editors/ox-input-chart-timeseries.js'\nimport '../src/chartjs/ox-chart-js.js'\nimport '../src/scichart/ox-scichart.js'\n\nimport { data, getDefaultChartConfig } from './common.js'\n\nexport default {\n title: 'ox-input-chart-timeseries',\n component: 'ox-input-chart-timeseries',\n argTypes: {\n value: { control: 'object' }\n }\n}\n\ninterface Story<T> {\n (args: T): TemplateResult\n args?: Partial<T>\n argTypes?: Record<string, unknown>\n}\n\ninterface ArgTypes {\n value: OperatoChart.ChartConfig\n}\n\nconst Template: Story<ArgTypes> = ({ value }: ArgTypes) => html`\n <link\n href=\"https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL@20..48,100..700,0..1\"\n rel=\"stylesheet\"\n />\n <link\n href=\"https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL@20..48,100..700,0..1\"\n rel=\"stylesheet\"\n />\n <link\n href=\"https://fonts.googleapis.com/css2?family=Material+Symbols+Sharp:opsz,wght,FILL@20..48,100..700,0..1\"\n rel=\"stylesheet\"\n />\n\n <link href=\"/themes/light.css\" rel=\"stylesheet\" />\n <link href=\"/themes/dark.css\" rel=\"stylesheet\" />\n <link href=\"/themes/spacing.css\" rel=\"stylesheet\" />\n\n <style>\n .container {\n width: 100%;\n height: 100%;\n\n display: flex;\n flex-direction: row;\n overflow-y: auto;\n padding: var(--spacing-medium);\n }\n\n .container.dark {\n background-color: black;\n }\n\n #editor {\n width: 300px;\n }\n\n #charts {\n flex: 1;\n\n display: flex;\n flex-direction: column;\n padding: 10px;\n }\n\n #chartjs {\n flex: 1;\n }\n\n #scichart {\n flex: 1;\n }\n </style>\n\n <div style=\"background-color: black; color: white;\">\n Type 'count' or 'average' for series dataKey, type 'year' for axis's dataKey\n </div>\n\n <div class=\"container light\">\n <ox-input-chart-timeseries\n chart-type=\"line\"\n id=\"editor\"\n .value=${value}\n @change=${(e: CustomEvent) => {\n const target = e.currentTarget as any\n const config = target.value\n const chartjs = document.querySelector('#chartjs') as HTMLElement\n if (chartjs) {\n ;(chartjs as any).config = { ...config }\n }\n const scichart = document.querySelector('#scichart') as HTMLElement\n if (scichart) {\n ;(scichart as any).config = config\n }\n\n const container = document.querySelector('.container') as HTMLElement\n if (container) {\n const theme = config.options.theme\n if (theme == 'dark') {\n container.classList.remove('light')\n container.classList.add('dark')\n } else {\n container.classList.remove('dark')\n container.classList.add('light')\n }\n }\n }}\n ></ox-input-chart-timeseries>\n <div id=\"charts\">\n <ox-scichart id=\"scichart\" .data=${data} attr-x=\"year\" attr-y=\"count\"></ox-scichart>\n <ox-chart-js id=\"chartjs\" .data=${data}></ox-chart-js>\n </div>\n </div>\n`\n\nexport const Default = Template.bind({})\nDefault.args = {}\n\nexport const WithData = Template.bind({})\nWithData.args = {\n value: {\n ...getDefaultChartConfig('line'),\n data: {\n datasets: [\n {\n dataKey: 'count',\n label: 'Line Series count',\n type: 'line',\n backgroundColor: 'rgba(255, 99, 132, 0.2)',\n borderColor: 'rgba(255, 99, 132, 1)',\n borderWidth: 1\n },\n {\n dataKey: 'average',\n label: 'Line Series average',\n type: 'line',\n borderColor: 'rgba(54, 162, 235, 1)',\n borderWidth: 1,\n fill: false,\n lineTension: 0.4,\n pointStyle: 'circle',\n pointRadius: 3\n }\n ],\n labelDataKey: 'year'\n },\n options: {\n scales: {\n xAxes: [{ ticks: { beginAtZero: true } }],\n yAxes: [{ ticks: { beginAtZero: true } }]\n },\n legend: { display: true }\n }\n }\n}\n\nexport const MultiAxis = Template.bind({})\nMultiAxis.args = {\n value: {\n ...getDefaultChartConfig('line'),\n options: {\n ...getDefaultChartConfig('line').options,\n multiAxis: true\n },\n data: {\n datasets: [\n {\n label: 'Bar Series',\n type: 'bar',\n backgroundColor: 'rgba(255, 99, 132, 0.2)',\n borderColor: 'rgba(255, 99, 132, 1)',\n borderWidth: 1,\n yAxisID: 'left'\n },\n {\n label: 'Line Series',\n type: 'line',\n borderColor: 'rgba(54, 162, 235, 1)',\n borderWidth: 1,\n fill: false,\n lineTension: 0.4,\n pointStyle: 'circle',\n pointRadius: 3,\n yAxisID: 'right'\n }\n ],\n labelDataKey: 'labels'\n }\n }\n}\n"]}
|