@operato/chart 8.0.0-beta.0 → 8.0.0-beta.2
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 +18 -0
- package/package.json +6 -6
- package/.editorconfig +0 -29
- package/.storybook/main.js +0 -3
- package/.storybook/preview.js +0 -52
- package/.storybook/server.mjs +0 -8
- package/demo/index.html +0 -33
- package/src/chartjs/config-converter.ts +0 -341
- package/src/chartjs/ox-chart-js.ts +0 -207
- package/src/editors/configurer.ts +0 -336
- package/src/editors/index.ts +0 -8
- package/src/editors/input-chart-abstract.ts +0 -202
- package/src/editors/input-chart-styles.ts +0 -206
- package/src/editors/ox-input-chart-hbar.ts +0 -157
- package/src/editors/ox-input-chart-mixed.ts +0 -241
- package/src/editors/ox-input-chart-pie.ts +0 -69
- package/src/editors/ox-input-chart-radar.ts +0 -56
- package/src/editors/ox-input-chart-timeseries.ts +0 -279
- package/src/editors/ox-property-editor-chart.ts +0 -72
- package/src/editors/templates/annotations.ts +0 -295
- package/src/editors/templates/display-value.ts +0 -111
- package/src/editors/templates/series.ts +0 -316
- package/src/global.d.ts +0 -1
- package/src/index.ts +0 -0
- package/src/progress/ox-progress-circle.ts +0 -133
- package/src/scichart/ox-scichart.ts +0 -151
- package/src/scichart/scichart-builder.ts +0 -508
- package/src/types.d.ts +0 -124
- package/stories/common.ts +0 -87
- package/stories/ox-input-chart-bar.stories.ts +0 -188
- package/stories/ox-input-chart-doughnut.stories.ts +0 -130
- package/stories/ox-input-chart-hbar.stories.ts +0 -188
- package/stories/ox-input-chart-line.stories.ts +0 -198
- package/stories/ox-input-chart-pie.stories.ts +0 -130
- package/stories/ox-input-chart-polar-area.stories.ts +0 -130
- package/stories/ox-input-chart-radar.stories.ts +0 -141
- package/stories/ox-input-chart-timeseries.stories.ts +0 -268
- package/tsconfig.json +0 -25
- package/web-dev-server.config.mjs +0 -27
- package/web-test-runner.config.mjs +0 -41
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,24 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [8.0.0-beta.2](https://github.com/hatiolab/operato/compare/v8.0.0-beta.1...v8.0.0-beta.2) (2025-01-08)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### :bug: Bug Fix
|
|
10
|
+
|
|
11
|
+
* typo .npmignore ([d9c0c8c](https://github.com/hatiolab/operato/commit/d9c0c8c79abc688c3c2cfb6c37fcb689483a5977))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## [8.0.0-beta.1](https://github.com/hatiolab/operato/compare/v8.0.0-beta.0...v8.0.0-beta.1) (2025-01-08)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### :bug: Bug Fix
|
|
19
|
+
|
|
20
|
+
* missing .npmignore ([be05985](https://github.com/hatiolab/operato/commit/be05985abfae4af53501f718dd52932099f7fbcb))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
6
24
|
## [8.0.0-beta.0](https://github.com/hatiolab/operato/compare/v8.0.0-alpha.56...v8.0.0-beta.0) (2025-01-07)
|
|
7
25
|
|
|
8
26
|
**Note:** Version bump only for package @operato/chart
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@operato/chart",
|
|
3
3
|
"description": "Webcomponents for chart following open-wc recommendations",
|
|
4
4
|
"author": "heartyoh@hatiolab.com",
|
|
5
|
-
"version": "8.0.0-beta.
|
|
5
|
+
"version": "8.0.0-beta.2",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
7
7
|
"module": "dist/src/index.js",
|
|
8
8
|
"types": "src/types.d.ts",
|
|
@@ -72,10 +72,10 @@
|
|
|
72
72
|
"dependencies": {
|
|
73
73
|
"@ctrl/tinycolor": "^4.1.0",
|
|
74
74
|
"@material/web": "^2.0.0",
|
|
75
|
-
"@operato/input": "^8.0.0-beta.
|
|
76
|
-
"@operato/property-editor": "^8.0.0-beta.
|
|
77
|
-
"@operato/styles": "^8.0.0-beta.
|
|
78
|
-
"@operato/utils": "^8.0.0-beta.
|
|
75
|
+
"@operato/input": "^8.0.0-beta.2",
|
|
76
|
+
"@operato/property-editor": "^8.0.0-beta.2",
|
|
77
|
+
"@operato/styles": "^8.0.0-beta.2",
|
|
78
|
+
"@operato/utils": "^8.0.0-beta.2",
|
|
79
79
|
"d3": "^7.8.5",
|
|
80
80
|
"lit": "^3.1.2",
|
|
81
81
|
"lodash-es": "^4.17.21",
|
|
@@ -119,5 +119,5 @@
|
|
|
119
119
|
"prettier --write"
|
|
120
120
|
]
|
|
121
121
|
},
|
|
122
|
-
"gitHead": "
|
|
122
|
+
"gitHead": "ee1b5124995accb99272d3b5854f3df1d8746dda"
|
|
123
123
|
}
|
package/.editorconfig
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# EditorConfig helps developers define and maintain consistent
|
|
2
|
-
# coding styles between different editors and IDEs
|
|
3
|
-
# editorconfig.org
|
|
4
|
-
|
|
5
|
-
root = true
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
[*]
|
|
9
|
-
|
|
10
|
-
# Change these settings to your own preference
|
|
11
|
-
indent_style = space
|
|
12
|
-
indent_size = 2
|
|
13
|
-
|
|
14
|
-
# We recommend you to keep these unchanged
|
|
15
|
-
end_of_line = lf
|
|
16
|
-
charset = utf-8
|
|
17
|
-
trim_trailing_whitespace = true
|
|
18
|
-
insert_final_newline = true
|
|
19
|
-
|
|
20
|
-
[*.md]
|
|
21
|
-
trim_trailing_whitespace = false
|
|
22
|
-
|
|
23
|
-
[*.json]
|
|
24
|
-
indent_size = 2
|
|
25
|
-
|
|
26
|
-
[*.{html,js,md}]
|
|
27
|
-
block_comment_start = /**
|
|
28
|
-
block_comment = *
|
|
29
|
-
block_comment_end = */
|
package/.storybook/main.js
DELETED
package/.storybook/preview.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { i18next } from '@operato/i18n'
|
|
2
|
-
|
|
3
|
-
export const globalTypes = {
|
|
4
|
-
locale: {
|
|
5
|
-
name: 'Locale',
|
|
6
|
-
description: 'Internationalization locale',
|
|
7
|
-
toolbar: {
|
|
8
|
-
icon: 'globe',
|
|
9
|
-
items: [
|
|
10
|
-
{ value: 'en', right: '🇺🇸', title: 'English' },
|
|
11
|
-
{ value: 'ko', right: '🇰🇷', title: '한국어' },
|
|
12
|
-
{ value: 'zh', right: '🇨🇳', title: '中文' },
|
|
13
|
-
{ value: 'ja', right: '🇯🇵', title: '日本語' },
|
|
14
|
-
{ value: 'ms', right: '🇲🇾', title: 'Bahasa Melayu' }
|
|
15
|
-
],
|
|
16
|
-
showName: true
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
theme: {
|
|
20
|
-
name: 'Theme',
|
|
21
|
-
description: 'Global theme for components',
|
|
22
|
-
toolbar: {
|
|
23
|
-
icon: 'paintbrush',
|
|
24
|
-
items: [
|
|
25
|
-
{ value: 'light', title: 'Light' },
|
|
26
|
-
{ value: 'dark', title: 'Dark' }
|
|
27
|
-
],
|
|
28
|
-
showName: true
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export const decorators = [
|
|
34
|
-
(Story, context) => {
|
|
35
|
-
const { locale, theme } = context.globals
|
|
36
|
-
|
|
37
|
-
if (locale) {
|
|
38
|
-
i18next.changeLanguage(locale)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Set the theme class for the document
|
|
42
|
-
if (theme === 'dark') {
|
|
43
|
-
document.documentElement.classList.add('dark')
|
|
44
|
-
document.documentElement.classList.remove('light')
|
|
45
|
-
} else {
|
|
46
|
-
document.documentElement.classList.add('light')
|
|
47
|
-
document.documentElement.classList.remove('dark')
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return Story()
|
|
51
|
-
}
|
|
52
|
-
]
|
package/.storybook/server.mjs
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { storybookPlugin } from '@web/dev-server-storybook'
|
|
2
|
-
import baseConfig from '../web-dev-server.config.mjs'
|
|
3
|
-
|
|
4
|
-
export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
|
|
5
|
-
...baseConfig,
|
|
6
|
-
open: '/',
|
|
7
|
-
plugins: [storybookPlugin({ type: 'web-components' }), ...baseConfig.plugins]
|
|
8
|
-
})
|
package/demo/index.html
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en-GB">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1" />
|
|
6
|
-
<style>
|
|
7
|
-
body {
|
|
8
|
-
background: #fafafa;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
a {
|
|
12
|
-
display: block;
|
|
13
|
-
}
|
|
14
|
-
</style>
|
|
15
|
-
<link href="/themes/app-theme.css" rel="stylesheet" />
|
|
16
|
-
<link href="/themes/input-theme.css" rel="stylesheet" />
|
|
17
|
-
<link
|
|
18
|
-
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL@20..48,100..700,0..1"
|
|
19
|
-
rel="stylesheet"
|
|
20
|
-
/>
|
|
21
|
-
<link
|
|
22
|
-
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL@20..48,100..700,0..1"
|
|
23
|
-
rel="stylesheet"
|
|
24
|
-
/>
|
|
25
|
-
<link
|
|
26
|
-
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Sharp:opsz,wght,FILL@20..48,100..700,0..1"
|
|
27
|
-
rel="stylesheet"
|
|
28
|
-
/>
|
|
29
|
-
</head>
|
|
30
|
-
<body>
|
|
31
|
-
<a href="./index-select.html">select</a>
|
|
32
|
-
</body>
|
|
33
|
-
</html>
|
|
@@ -1,341 +0,0 @@
|
|
|
1
|
-
import { TinyColor } from '@ctrl/tinycolor'
|
|
2
|
-
import { format as formatText } from '@operato/utils/format.js'
|
|
3
|
-
|
|
4
|
-
function getBaseColorFromTheme(theme?: 'light' | 'dark' | 'auto') {
|
|
5
|
-
return new TinyColor(theme == 'dark' ? '#fff' : '#000')
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
function getThemeFromBrowser() {
|
|
9
|
-
return window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function convertConfigure(
|
|
13
|
-
config: OperatoChart.ChartConfig,
|
|
14
|
-
{ fontSize, fontFamily, fontColor }: { fontSize?: number; fontFamily?: string; fontColor?: string }
|
|
15
|
-
) {
|
|
16
|
-
if (!config) {
|
|
17
|
-
return
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const { type: chartType, options, data: fromData } = config
|
|
21
|
-
var {
|
|
22
|
-
theme,
|
|
23
|
-
animation,
|
|
24
|
-
tooltip,
|
|
25
|
-
stacked,
|
|
26
|
-
legend,
|
|
27
|
-
scales: fromScales,
|
|
28
|
-
xGridLine,
|
|
29
|
-
yGridLine,
|
|
30
|
-
y2ndGridLine,
|
|
31
|
-
multiAxis
|
|
32
|
-
} = options || {}
|
|
33
|
-
const { datasets = [] } = fromData || {}
|
|
34
|
-
|
|
35
|
-
if (theme === 'auto') {
|
|
36
|
-
theme = getThemeFromBrowser()
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const { xAxes = [], yAxes = [] } = fromScales || {}
|
|
40
|
-
const toScales = {} as any
|
|
41
|
-
|
|
42
|
-
chartType != 'pie' &&
|
|
43
|
-
xAxes.forEach((xAxis, index) => {
|
|
44
|
-
const { axisTitle, barSpacing, categorySpacing, barPercentage, ticks } = xAxis
|
|
45
|
-
const id = xAxes.length > 1 ? `x${index + 1}` : 'x'
|
|
46
|
-
|
|
47
|
-
toScales[id] = setupScale(
|
|
48
|
-
{
|
|
49
|
-
axis: 'x',
|
|
50
|
-
id,
|
|
51
|
-
position: 'bottom',
|
|
52
|
-
display: true,
|
|
53
|
-
title: {
|
|
54
|
-
display: !!axisTitle,
|
|
55
|
-
text: axisTitle
|
|
56
|
-
},
|
|
57
|
-
grid: {
|
|
58
|
-
display: xGridLine
|
|
59
|
-
},
|
|
60
|
-
beginAtZero: false,
|
|
61
|
-
ticks
|
|
62
|
-
},
|
|
63
|
-
{ fontSize, fontFamily, fontColor, theme }
|
|
64
|
-
)
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
chartType != 'pie' &&
|
|
68
|
-
yAxes.forEach((yAxis, index) => {
|
|
69
|
-
const { axisTitle, barSpacing, categorySpacing, barPercentage, ticks } = yAxis
|
|
70
|
-
const id = yAxes.length > 1 ? `right` : 'left'
|
|
71
|
-
|
|
72
|
-
toScales[id] = setupScale(
|
|
73
|
-
{
|
|
74
|
-
axis: 'y',
|
|
75
|
-
id,
|
|
76
|
-
position: id,
|
|
77
|
-
display: true,
|
|
78
|
-
title: {
|
|
79
|
-
display: !!axisTitle,
|
|
80
|
-
text: axisTitle
|
|
81
|
-
},
|
|
82
|
-
grid: {
|
|
83
|
-
display: index == 0 ? yGridLine : y2ndGridLine
|
|
84
|
-
},
|
|
85
|
-
ticks,
|
|
86
|
-
stacked: stacked ? true : false
|
|
87
|
-
},
|
|
88
|
-
{ fontSize, fontFamily, fontColor, theme }
|
|
89
|
-
)
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
// setup series configure
|
|
93
|
-
// for (let i in datasets) {
|
|
94
|
-
// let series = datasets[i]
|
|
95
|
-
//
|
|
96
|
-
// /*
|
|
97
|
-
// * TODO from chartjs 2.9, categoryPercentage, barPercentage properties move to dataset.
|
|
98
|
-
// * so need to move related properties - categorySpacing, barSpacing should be moved to series.
|
|
99
|
-
// */
|
|
100
|
-
// if (chartType == 'bar') {
|
|
101
|
-
// let categorySpacing = (xAxes && xAxes[0].categorySpacing) || 0
|
|
102
|
-
// let barSpacing = (xAxes && xAxes[0].barSpacing) || 0
|
|
103
|
-
|
|
104
|
-
// series.categoryPercentage = 1 - categorySpacing || 1
|
|
105
|
-
// series.barPercentage = 1 - barSpacing || 0.8
|
|
106
|
-
// } else if (chartType == 'horizontalBar') {
|
|
107
|
-
// let categorySpacing = (yAxes && yAxes[0].categorySpacing) || 0
|
|
108
|
-
// let barSpacing = (yAxes && yAxes[0].barSpacing) || 0
|
|
109
|
-
|
|
110
|
-
// series.categoryPercentage = 1 - categorySpacing || 1
|
|
111
|
-
// series.barPercentage = 1 - barSpacing || 0.8
|
|
112
|
-
// }
|
|
113
|
-
// }
|
|
114
|
-
|
|
115
|
-
const converted = {
|
|
116
|
-
type: chartType == 'horizontalBar' ? 'bar' : chartType,
|
|
117
|
-
options: {
|
|
118
|
-
animation,
|
|
119
|
-
stacked,
|
|
120
|
-
maintainAspectRatio: false,
|
|
121
|
-
// parsing: false /* recommendations for performance */,
|
|
122
|
-
// normalized: true /* recommendations for performance */,
|
|
123
|
-
plugins: {
|
|
124
|
-
legend: setupLegend(legend || {}, { fontSize, fontFamily, fontColor, theme }),
|
|
125
|
-
tooltip: setupTooltip(
|
|
126
|
-
{
|
|
127
|
-
enabled: tooltip,
|
|
128
|
-
mode: 'interpolate',
|
|
129
|
-
intersect: false
|
|
130
|
-
},
|
|
131
|
-
{ fontSize, fontFamily }
|
|
132
|
-
),
|
|
133
|
-
title: {
|
|
134
|
-
/* new option candidate - subtitle */
|
|
135
|
-
display: false,
|
|
136
|
-
text: 'Custom Chart Title'
|
|
137
|
-
},
|
|
138
|
-
subtitle: {
|
|
139
|
-
/* new option candidate - subtitle */
|
|
140
|
-
display: false,
|
|
141
|
-
text: 'Custom Chart Subtitle'
|
|
142
|
-
},
|
|
143
|
-
crosshair: {
|
|
144
|
-
line: {
|
|
145
|
-
color: '#F66', // crosshair line color
|
|
146
|
-
width: 1 // crosshair line width
|
|
147
|
-
},
|
|
148
|
-
sync: {
|
|
149
|
-
enabled: true, // enable trace line syncing with other charts
|
|
150
|
-
group: 1, // chart group
|
|
151
|
-
suppressTooltips: false // suppress tooltips when showing a synced tracer
|
|
152
|
-
},
|
|
153
|
-
zoom: {
|
|
154
|
-
enabled: true, // enable zooming
|
|
155
|
-
zoomboxBackgroundColor: 'rgba(66,133,244,0.2)', // background color of zoom box
|
|
156
|
-
zoomboxBorderColor: '#48F', // border color of zoom box
|
|
157
|
-
zoomButtonText: 'Reset Zoom', // reset zoom button text
|
|
158
|
-
zoomButtonClass: 'reset-zoom' // reset zoom button class
|
|
159
|
-
},
|
|
160
|
-
callbacks: {
|
|
161
|
-
beforeZoom: () =>
|
|
162
|
-
function (start: number, end: number) {
|
|
163
|
-
// called before zoom, return false to prevent zoom
|
|
164
|
-
return true
|
|
165
|
-
},
|
|
166
|
-
afterZoom: () =>
|
|
167
|
-
function (start: number, end: number) {
|
|
168
|
-
// called after zoom
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
},
|
|
173
|
-
scales: toScales,
|
|
174
|
-
indexAxis: chartType == 'horizontalBar' ? 'y' : chartType != 'pie' ? 'x' : ''
|
|
175
|
-
},
|
|
176
|
-
data: {
|
|
177
|
-
datasets: datasets.map((dataset, index) => {
|
|
178
|
-
return setupSeries(chartType!, {
|
|
179
|
-
...dataset,
|
|
180
|
-
stack:
|
|
181
|
-
chartType == 'pie' || chartType == 'doughnut'
|
|
182
|
-
? undefined
|
|
183
|
-
: stacked && !dataset.stack
|
|
184
|
-
? '__all__'
|
|
185
|
-
: `__${index}__`,
|
|
186
|
-
type: dataset.type == 'horizontalBar' ? 'bar' : dataset.type
|
|
187
|
-
})
|
|
188
|
-
})
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
console.error('converted', config, converted)
|
|
193
|
-
return converted
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
function setupLegend(
|
|
197
|
-
legend: any,
|
|
198
|
-
{
|
|
199
|
-
fontSize,
|
|
200
|
-
fontFamily,
|
|
201
|
-
fontColor,
|
|
202
|
-
theme
|
|
203
|
-
}: { fontSize?: number; fontFamily?: string; fontColor?: string; theme?: 'light' | 'dark' | 'auto' }
|
|
204
|
-
) {
|
|
205
|
-
legend.labels = legend.labels ? legend.labels : {}
|
|
206
|
-
|
|
207
|
-
if (fontSize) {
|
|
208
|
-
legend.labels.fontSize = fontSize
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
if (fontFamily) {
|
|
212
|
-
legend.labels.fontFamily = fontFamily
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
var baseColor = getBaseColorFromTheme(theme)
|
|
216
|
-
|
|
217
|
-
legend.labels = legend.labels ? legend.labels : {}
|
|
218
|
-
legend.labels.fontColor = fontColor ? fontColor : baseColor.clone().setAlpha(0.5).toString()
|
|
219
|
-
// legend.labels.usePointStyle = true
|
|
220
|
-
|
|
221
|
-
return legend
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
function setupTooltip(
|
|
225
|
-
tooltip: any,
|
|
226
|
-
{
|
|
227
|
-
fontSize,
|
|
228
|
-
fontFamily,
|
|
229
|
-
fontColor,
|
|
230
|
-
theme
|
|
231
|
-
}: { fontSize?: number; fontFamily?: string; fontColor?: string; theme?: 'light' | 'dark' }
|
|
232
|
-
) {
|
|
233
|
-
if (fontSize) {
|
|
234
|
-
tooltip.titleFontSize = tooltip.bodyFontSize = tooltip.footerFontSize = fontSize
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
if (fontFamily) {
|
|
238
|
-
tooltip.titleFontFamily = tooltip.bodyFontFamily = tooltip.footerFontFamily = fontFamily
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
tooltip.mode = 'index'
|
|
242
|
-
tooltip.intersect = false
|
|
243
|
-
tooltip.callbacks = {
|
|
244
|
-
...tooltip.callbacks,
|
|
245
|
-
label: function ({ dataset, label }: { dataset: any; label: any }) {
|
|
246
|
-
var prefix = dataset.valuePrefix || ''
|
|
247
|
-
var suffix = dataset.valueSuffix || ''
|
|
248
|
-
var format = dataset.valueFormat || ''
|
|
249
|
-
|
|
250
|
-
var stringValue = format ? formatText(format, Number(label)) : Number(label).toLocaleString()
|
|
251
|
-
|
|
252
|
-
return `${prefix + stringValue + suffix}`
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
return tooltip
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
function setupScale(
|
|
260
|
-
axis: any,
|
|
261
|
-
{
|
|
262
|
-
fontSize,
|
|
263
|
-
fontFamily,
|
|
264
|
-
fontColor,
|
|
265
|
-
theme
|
|
266
|
-
}: { fontSize?: number; fontFamily?: string; fontColor?: string; theme?: 'light' | 'dark' | 'auto' }
|
|
267
|
-
) {
|
|
268
|
-
axis.ticks = axis.ticks ? axis.ticks : {}
|
|
269
|
-
|
|
270
|
-
if (fontSize) {
|
|
271
|
-
axis.ticks.fontSize = fontSize
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
if (fontFamily) {
|
|
275
|
-
axis.ticks.fontFamily = fontFamily
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
axis.pointLabels = {
|
|
279
|
-
fontSize,
|
|
280
|
-
fontFamily
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
/* TODO move min, max, autoMin, autoMax from ticks to axis */
|
|
284
|
-
const { min, max, autoMin, autoMax } = axis.ticks
|
|
285
|
-
|
|
286
|
-
axis.min = min
|
|
287
|
-
axis.max = max
|
|
288
|
-
|
|
289
|
-
if (autoMin) {
|
|
290
|
-
delete axis.min
|
|
291
|
-
}
|
|
292
|
-
if (autoMax) {
|
|
293
|
-
delete axis.max
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
var baseColor = getBaseColorFromTheme(theme)
|
|
297
|
-
|
|
298
|
-
axis.grid = axis.grid ? axis.grid : {}
|
|
299
|
-
if (axis.grid) {
|
|
300
|
-
axis.grid.tickColor = baseColor.clone().setAlpha(0.5).toString()
|
|
301
|
-
axis.grid.color = baseColor.clone().setAlpha(0.1).toString()
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
axis.ticks = axis.ticks ? axis.ticks : {}
|
|
305
|
-
axis.ticks.color = baseColor.clone().setAlpha(0.5).toString()
|
|
306
|
-
axis.ticks.textStrokeColor = fontColor ? fontColor : baseColor.clone().setAlpha(0.5).toString()
|
|
307
|
-
|
|
308
|
-
return axis
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
function setupSeries(chartType: string, series: OperatoChart.Dataset) {
|
|
312
|
-
var type = series.type || chartType
|
|
313
|
-
|
|
314
|
-
// series.parsing = {
|
|
315
|
-
// yAxisKey: series.dataKey
|
|
316
|
-
// } /* 이 형식의 data는 잘 안되었음. */
|
|
317
|
-
|
|
318
|
-
var color = series.color ? series.color : series.backgroundColor
|
|
319
|
-
|
|
320
|
-
switch (type) {
|
|
321
|
-
case 'bar':
|
|
322
|
-
case 'horizontalBar':
|
|
323
|
-
series.borderColor = series.backgroundColor = color
|
|
324
|
-
break
|
|
325
|
-
|
|
326
|
-
case 'line':
|
|
327
|
-
case 'radar':
|
|
328
|
-
color = series.color ? series.color : series.borderColor
|
|
329
|
-
series.pointBackgroundColor = series.pointBorderColor = series.borderColor = series.backgroundColor = color
|
|
330
|
-
series.pointBorderWidth = (series.borderWidth as number) * 0.5
|
|
331
|
-
series.pointHoverRadius = series.pointRadius
|
|
332
|
-
if (series.fill == undefined) series.fill = false
|
|
333
|
-
break
|
|
334
|
-
|
|
335
|
-
default:
|
|
336
|
-
series.borderColor = series.backgroundColor = color
|
|
337
|
-
break
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
return series
|
|
341
|
-
}
|