visualifyjs 2.5.3-2.dev

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. package/.github/workflows/static.yml.bak +51 -0
  2. package/LICENSE +674 -0
  3. package/README.md +59 -0
  4. package/config-overrides.js +31 -0
  5. package/dist/visualify.js +188 -0
  6. package/docs/.nojekyll +0 -0
  7. package/docs/docs/CLI.md +34 -0
  8. package/docs/docs/README.md +65 -0
  9. package/docs/docs/Rechart/bar.md +190 -0
  10. package/docs/docs/Rechart/funnel.md +241 -0
  11. package/docs/docs/Rechart/geo.md +0 -0
  12. package/docs/docs/Rechart/line.md +355 -0
  13. package/docs/docs/Rechart/liquidfill.md +0 -0
  14. package/docs/docs/Rechart/pie.md +225 -0
  15. package/docs/docs/Rechart/polar.md +0 -0
  16. package/docs/docs/Rechart/radar.md +253 -0
  17. package/docs/docs/Rechart/sankey.md +0 -0
  18. package/docs/docs/Rechart/scatter.md +298 -0
  19. package/docs/docs/Rechart/sunburst.md +0 -0
  20. package/docs/docs/Rechart/tree.md +0 -0
  21. package/docs/docs/Rechart/wordcloud.md +0 -0
  22. package/docs/docs/_404.md +52 -0
  23. package/docs/docs/_coverpage.md +11 -0
  24. package/docs/docs/_sidebar.md +44 -0
  25. package/docs/docs/components/dotBio.md +34 -0
  26. package/docs/docs/components/echart.md +82 -0
  27. package/docs/docs/components/html.md +34 -0
  28. package/docs/docs/components/macaron.md +145 -0
  29. package/docs/docs/components/markdown.md +0 -0
  30. package/docs/docs/components/more.md +142 -0
  31. package/docs/docs/components/plotly.md +62 -0
  32. package/docs/docs/components/scatterL.md +70 -0
  33. package/docs/docs/components/visium.md +57 -0
  34. package/docs/docs/configuration.md +121 -0
  35. package/docs/docs/deploy.md +31 -0
  36. package/docs/docs/log.md +9 -0
  37. package/docs/docs/more-pages.md +23 -0
  38. package/docs/docs/quickstart.md +124 -0
  39. package/docs/docs/rechart-attributes.md +74 -0
  40. package/docs/docs/rechart-basic-usage.md +162 -0
  41. package/docs/docs/static/_images/deploy-github-pages.png +0 -0
  42. package/docs/docs/static/logo/favicon.ico +0 -0
  43. package/docs/docs/static/logo/logo_128x128.png +0 -0
  44. package/docs/docs/static/logo/logo_192x192.png +0 -0
  45. package/docs/docs/static/logo/logo_256x256.png +0 -0
  46. package/docs/docs/static/logo/logo_512x512.png +0 -0
  47. package/docs/docs/static/logo/logo_64x64.png +0 -0
  48. package/docs/docs/theme.md +5 -0
  49. package/docs/index.html +71 -0
  50. package/docs/manifest.json +24 -0
  51. package/docs/static/css/fluff-stuff.css +170 -0
  52. package/docs/static/css/font-awesome.min.css +4 -0
  53. package/docs/static/css/visualify.css +25 -0
  54. package/docs/static/fonts/fontawesome-webfont.woff2 +0 -0
  55. package/docs/static/images/star.png +0 -0
  56. package/docs/static/js/configuration.js +448 -0
  57. package/docs/static/js/fluff.js +1 -0
  58. package/docs/static/js/visualify.js +188 -0
  59. package/docs/static/logo/favicon.ico +0 -0
  60. package/docs/static/logo/logo_128x128.png +0 -0
  61. package/docs/static/logo/logo_192x192.png +0 -0
  62. package/docs/static/logo/logo_256x256.png +0 -0
  63. package/docs/static/logo/logo_512x512.png +0 -0
  64. package/docs/static/logo/logo_64x64.png +0 -0
  65. package/package.json +84 -0
  66. package/rollup.config.mjs +76 -0
  67. package/src/_css/404.css +116 -0
  68. package/src/_css/App.css +38 -0
  69. package/src/_css/autoSuggestion.css +27 -0
  70. package/src/_css/circular-progress.css +33 -0
  71. package/src/_css/index.css +37 -0
  72. package/src/_css/modern.css +25 -0
  73. package/src/_media/404.png +0 -0
  74. package/src/_media/corner.svg +8 -0
  75. package/src/_media/download.svg +3 -0
  76. package/src/_media/icon.svg +1 -0
  77. package/src/_media/logo.svg +14 -0
  78. package/src/_test/App.test.js +15 -0
  79. package/src/_utils/reportWebVitals.js +13 -0
  80. package/src/core/appContext.js +27 -0
  81. package/src/core/components/Scatter.js +188 -0
  82. package/src/core/components/ScatterBio.js +572 -0
  83. package/src/core/components/VisiumPlot.js +165 -0
  84. package/src/core/components/browser.js +42 -0
  85. package/src/core/components/dotplot.js +413 -0
  86. package/src/core/components/html.js +29 -0
  87. package/src/core/components/list.js +178 -0
  88. package/src/core/components/macaron.js +201 -0
  89. package/src/core/components/markdown.js +56 -0
  90. package/src/core/components/parser.scatterBio.js +587 -0
  91. package/src/core/components/ratio.js +80 -0
  92. package/src/core/components/scatterL.js +173 -0
  93. package/src/core/components/searchbar.js +131 -0
  94. package/src/core/components/selection.js +193 -0
  95. package/src/core/components/timeline.js +281 -0
  96. package/src/core/components/visium.js +97 -0
  97. package/src/core/fetch/condfetch.js +82 -0
  98. package/src/core/fetch/fetch.js +92 -0
  99. package/src/core/fetch/json.js +29 -0
  100. package/src/core/fetch/vfetch.js +42 -0
  101. package/src/core/liveEditor.js +44 -0
  102. package/src/core/modules/codeEditorWithPreview.js +104 -0
  103. package/src/core/modules/echarts/common.js +20 -0
  104. package/src/core/modules/echarts/presetHandler.js +41 -0
  105. package/src/core/modules/echarts/presets/esodev.chromium.js +172 -0
  106. package/src/core/modules/echarts/presets/esodev.codex.js +130 -0
  107. package/src/core/modules/echarts/presets/esodev.visium.js +123 -0
  108. package/src/core/modules/echarts/presets/mmtrbc.js +186 -0
  109. package/src/core/modules/echarts.js +71 -0
  110. package/src/core/modules/echartsUtils.js +43 -0
  111. package/src/core/modules/echartswitcher.js +152 -0
  112. package/src/core/modules/replotly/presetHandler.js +24 -0
  113. package/src/core/modules/replotly/presets/minimum.js +18 -0
  114. package/src/core/modules/replotly/presets/mmtrbc.dot.js +114 -0
  115. package/src/core/modules/replotly/presets/mmtrbc.violin.js +100 -0
  116. package/src/core/modules/replotly.js +71 -0
  117. package/src/core/pages/404.js +50 -0
  118. package/src/core/pages/error.js +27 -0
  119. package/src/core/pages/jsonPage.js +62 -0
  120. package/src/core/pages/loading.js +44 -0
  121. package/src/core/parser/echart.data.js +183 -0
  122. package/src/core/parser/echart.features.js +125 -0
  123. package/src/core/parser/echart.general.js +147 -0
  124. package/src/core/parser/echart.hilbert.js +57 -0
  125. package/src/core/parser/echart.parser.js +210 -0
  126. package/src/core/parser/echart.series.js +67 -0
  127. package/src/core/parser/echart.types.js +76 -0
  128. package/src/core/parser/plotly.config.js +10 -0
  129. package/src/core/parser/plotly.data.js +132 -0
  130. package/src/core/parser/plotly.layout.js +10 -0
  131. package/src/core/parser/plotly.violin.js +18 -0
  132. package/src/core/recharts.js +62 -0
  133. package/src/core/router/alias.js +49 -0
  134. package/src/core/router/jsonRouter.js +31 -0
  135. package/src/core/themes/modern.js +32 -0
  136. package/src/core/themes/themeSelector.js +33 -0
  137. package/src/core/visualify.js +47 -0
  138. package/src/core/widgets/circularProgress.js +24 -0
  139. package/src/core/widgets/controller.js +83 -0
  140. package/src/core/widgets/errorBoundary.js +36 -0
  141. package/src/core/widgets/footer.js +177 -0
  142. package/src/core/widgets/header.js +234 -0
  143. package/src/core/widgets/layout/Grid.js +31 -0
  144. package/src/core/widgets/layout.js +36 -0
  145. package/src/core/widgets/mapping.js +42 -0
  146. package/src/index.js +62 -0
  147. package/src/setupTests.js +5 -0
@@ -0,0 +1,71 @@
1
+ /*
2
+ * @Author : Lihao leolihao@arizona.edu
3
+ * @Date : 2024-01-14 14:39:52
4
+ * @FilePath : /visualifyjs/src/core/modules/replotly.js
5
+ * @Description :
6
+ * Copyright (c) 2024 by Lihao (leolihao@arizona.edu), All Rights Reserved.
7
+ */
8
+ import React, { useEffect, useState } from 'react';
9
+ import Plot from 'react-plotly.js';
10
+ import { getPreset } from './replotly/presetHandler';
11
+ import { useAppContext } from '../appContext';
12
+ import handle_Data, { __process_fetched_data } from '../parser/plotly.data';
13
+ import { handle_violin_plot } from '../parser/plotly.violin';
14
+
15
+ const RePlotly = ({ props, style }) => {
16
+ const [data, setData] = useState(props.data ?? []);
17
+ const [layout, setLayout] = useState(props.layout ?? {});
18
+ const [config, setConfig] = useState(props.config ?? {});
19
+ const { sharedData } = useAppContext();
20
+
21
+ useEffect(() => {
22
+ const updatePlot = async () => {
23
+ const { settings, parser } = props;
24
+ let preset = getPreset(settings?.preset);
25
+ if (parser) {
26
+ try {
27
+ // fetch data from api
28
+ const fetched_data = await handle_Data(
29
+ parser,
30
+ preset.layout,
31
+ sharedData,
32
+ );
33
+ const processed_data = __process_fetched_data(
34
+ fetched_data,
35
+ parser,
36
+ preset.visualify,
37
+ );
38
+
39
+ if (parser.type === 'violin') {
40
+ preset.data = handle_violin_plot(processed_data);
41
+ setData(() => preset.data);
42
+ }
43
+ } catch (err) {
44
+ if (
45
+ err.message === 'No data fetched from api' &&
46
+ settings?.ignoreEmptyData
47
+ ) {
48
+ } else console.log(err.message);
49
+ }
50
+ }
51
+
52
+ setData((data) => [...preset.data]);
53
+ setLayout((layout) => ({ ...preset.layout }));
54
+ setConfig((config) => ({ ...preset.config }));
55
+ };
56
+
57
+ updatePlot();
58
+ }, [props, sharedData]);
59
+
60
+ return (
61
+ <div style={style}>
62
+ <Plot
63
+ data={data}
64
+ layout={layout}
65
+ config={config}
66
+ />
67
+ </div>
68
+ );
69
+ };
70
+
71
+ export default RePlotly;
@@ -0,0 +1,50 @@
1
+ /*
2
+ * @Author : Lihao leolihao@arizona.edu
3
+ * @Date : 2023-11-30 21:58:47
4
+ * @FilePath : /visualifyjs/src/core/pages/404.js
5
+ * @Description :
6
+ * Copyright (c) 2023 by Lihao (leolihao@arizona.edu), All Rights Reserved.
7
+ */
8
+ import React from 'react';
9
+ import '../../_css/404.css';
10
+
11
+ const NotFoundPage = ({ page, config = {} }) => {
12
+ const {
13
+ heading = (
14
+ <span>
15
+ Oops! This Page <span style={{ color: 'red' }}>{page}</span>{' '}
16
+ Could Not Be Found
17
+ </span>
18
+ ),
19
+ content = 'SORRY BUT THE PAGE YOU ARE LOOKING FOR DOES NOT EXIST, HAVE BEEN REMOVED, NAME CHANGED, OR IS TEMPORARILY UNAVAILABLE',
20
+ button_text = 'BACK TO HOME',
21
+ } = config;
22
+
23
+ return (
24
+ <div id='colorlib-notfound'>
25
+ <div className='colorlib-notfound'>
26
+ <div className='colorlib-notfound-404'>
27
+ <h1>404</h1>
28
+ </div>
29
+ <h2 id='colorlib_404_customizer_page_heading'>{heading}</h2>
30
+ <div id='colorlib_404_customizer_content'>{content}</div>
31
+ <a
32
+ href={window.location.origin}
33
+ id='colorlib_404_customizer_button_text'>
34
+ {button_text}
35
+ </a>
36
+ </div>
37
+ <p className='colorlib-copyrigh'>
38
+ <span>404 Page Template designed by </span>
39
+ <a
40
+ href='https://colorlib.com/'
41
+ target='_blank'
42
+ rel='noopener noreferrer'>
43
+ Colorlib.
44
+ </a>
45
+ </p>
46
+ </div>
47
+ );
48
+ };
49
+
50
+ export default NotFoundPage;
@@ -0,0 +1,27 @@
1
+ /*
2
+ * @Author : Lihao leolihao@arizona.edu
3
+ * @Date : 2023-12-23 13:22:50
4
+ * @FilePath : /visualifyjs/src/core/pages/error.js
5
+ * @Description :
6
+ * Copyright (c) 2023 by Lihao (leolihao@arizona.edu), All Rights Reserved.
7
+ */
8
+ import React from 'react';
9
+
10
+ function Error({ message, style }) {
11
+ return (
12
+ <div
13
+ style={{
14
+ display: 'flex',
15
+ alignItems: 'center',
16
+ justifyContent: 'center',
17
+ height: '100%',
18
+ color: 'red',
19
+ ...style,
20
+ }}>
21
+ {/* Display the error message */}
22
+ <p>{message}</p>
23
+ </div>
24
+ );
25
+ }
26
+
27
+ export default Error;
@@ -0,0 +1,62 @@
1
+ /*
2
+ * @Author : Lihao leolihao@arizona.edu
3
+ * @Date : 2023-11-29 21:20:55
4
+ * @FilePath : /visualifyjs/src/core/pages/jsonPage.js
5
+ * @Description :
6
+ * Copyright (c) 2023 by Lihao (leolihao@arizona.edu), All Rights Reserved.
7
+ */
8
+ import React, { useEffect, useState } from 'react';
9
+ import { useLocation } from 'react-router-dom';
10
+ import NotFoundPage from './404';
11
+ import fetchJson from '../fetch/json';
12
+ import LayoutParser from '../widgets/layout';
13
+ import Vcontroller from '../widgets/controller';
14
+
15
+ const JsonPage = () => {
16
+ const [jsonData, setJsonData] = useState(null);
17
+ const [loading, setLoading] = useState(true);
18
+ const [error, setError] = useState(null);
19
+ const location = useLocation();
20
+
21
+ useEffect(() => {
22
+ const routerpath = location.pathname.replace(/^\/|\.json$/g, '');
23
+ const jsonurl =
24
+ routerpath === ''
25
+ ? 'home'
26
+ : routerpath.endsWith('/')
27
+ ? routerpath + 'home'
28
+ : routerpath;
29
+ //console.log('JsonPage jsonurl:', jsonurl);
30
+ if (jsonurl) {
31
+ setLoading(true);
32
+ setError(null);
33
+
34
+ fetchJson(jsonurl)
35
+ .then((data) => {
36
+ setJsonData(data);
37
+ setLoading(false);
38
+ })
39
+ .catch((err) => {
40
+ setError(err);
41
+ setLoading(false);
42
+ });
43
+ }
44
+ }, [location.pathname]); // React to changes in pathname
45
+
46
+ if (loading) {
47
+ return <div>Loading...</div>;
48
+ }
49
+ if (error || !jsonData) {
50
+ return <NotFoundPage page={location.pathname} />;
51
+ }
52
+
53
+ return (
54
+ <>
55
+ <LayoutParser config={jsonData.layout}>
56
+ <Vcontroller components={jsonData.components} />
57
+ </LayoutParser>
58
+ </>
59
+ );
60
+ };
61
+
62
+ export default JsonPage;
@@ -0,0 +1,44 @@
1
+ /*
2
+ * @Author : Lihao leolihao@arizona.edu
3
+ * @Date : 2023-12-23 13:22:33
4
+ * @FilePath : /visualifyjs/src/core/pages/Loading.js
5
+ * @Description :
6
+ * Copyright (c) 2023 by Lihao (leolihao@arizona.edu), All Rights Reserved.
7
+ */
8
+ import React from 'react';
9
+ import Error from './error';
10
+ import CircularProgress from '../widgets/circularProgress';
11
+
12
+ function Loading({
13
+ message,
14
+ style,
15
+ msgStyle,
16
+ ProgressColor = 'primary',
17
+ error = false,
18
+ }) {
19
+ return (
20
+ <div
21
+ style={{
22
+ display: 'flex',
23
+ flexDirection: 'column', // Added to stack elements vertically
24
+ alignItems: 'center',
25
+ justifyContent: 'center',
26
+ height: '100%',
27
+ ...style,
28
+ }}>
29
+ <CircularProgress color={ProgressColor} />
30
+ <div style={{ marginTop: '10px', ...msgStyle }}>
31
+ {error ? (
32
+ <Error
33
+ message={message}
34
+ style={msgStyle}
35
+ />
36
+ ) : (
37
+ <p>{message}</p>
38
+ )}
39
+ </div>
40
+ </div>
41
+ );
42
+ }
43
+
44
+ export default Loading;
@@ -0,0 +1,183 @@
1
+ /*
2
+ * @Author : Lihao leolihao@arizona.edu
3
+ * @Date : 2023-12-02 16:52:58
4
+ * @FilePath : /visualifyjs/src/core/parser/echart.data.js
5
+ * @Description :
6
+ * Copyright (c) 2023 by Lihao (leolihao@arizona.edu), All Rights Reserved.
7
+ */
8
+ import { getArrayEl, _handleSeries } from './echart.series';
9
+ import {
10
+ _parsePeakvalley,
11
+ _parseMarkArea,
12
+ _parseMarkLine,
13
+ } from './echart.features';
14
+
15
+ const _parser_data = (options = {}, preset = {}) => {
16
+ // Parse the custom options
17
+ const parsedOptions = {
18
+ ...preset,
19
+ yAxis: { ...preset.yAxis },
20
+ xAxis: { ...preset.xAxis },
21
+ legend: { ...preset.legend },
22
+ title: { ...preset.title },
23
+ tooltip: { ...preset.tooltip },
24
+ // ... other default settings for charts
25
+ series: [],
26
+ };
27
+
28
+ // Initialize totalValues array if percentage mode is active
29
+ let totalValues = options.percentage
30
+ ? new Array(options.xAxis.length).fill(0)
31
+ : [];
32
+
33
+ // calculate total values if in percentage mode
34
+ if (options.percentage && options.data) {
35
+ Object.entries(options.data).forEach(([_, data]) => {
36
+ data.forEach((value, idx) => {
37
+ totalValues[idx] += value;
38
+ });
39
+ });
40
+ }
41
+
42
+ if (options.data && typeof options.data === 'object') {
43
+ parsedOptions.series = Object.entries(options.data).map(
44
+ ([name, data], index) => {
45
+ let seriesObject = {
46
+ name,
47
+ type: getArrayEl(options.type, index),
48
+ data,
49
+ ...(options.markArea && {
50
+ markArea: _parseMarkArea(options.markArea, index),
51
+ }),
52
+ ...(options.markLine && {
53
+ markLine: _parseMarkLine(options.markLine, index),
54
+ }),
55
+ ...(options.symbol && {
56
+ symbol: getArrayEl(options.symbol, index),
57
+ }),
58
+ ...(options.symbolSize && {
59
+ symbolSize: getArrayEl(options.symbolSize, index),
60
+ }),
61
+ ...(options.stack && {
62
+ stack: options.stack.includes(name)
63
+ ? 'total'
64
+ : getArrayEl(options.stack, index),
65
+ }),
66
+ ...(options.emphasis && {
67
+ emphasis: getArrayEl(options.emphasis, index),
68
+ }),
69
+ };
70
+
71
+ if (
72
+ options.percentage &&
73
+ (options.type === 'bar' || options.type === 'line')
74
+ ) {
75
+ seriesObject.data = seriesObject.data.map(
76
+ (value, idx) => (value / totalValues[idx]) * 100,
77
+ );
78
+ seriesObject.stack = 'total';
79
+ }
80
+
81
+ if (options.waterfall) {
82
+ if (name === 'Placeholder' || name === options.waterfall) {
83
+ seriesObject.itemStyle = {
84
+ borderColor: 'transparent',
85
+ color: 'transparent',
86
+ };
87
+ seriesObject = {
88
+ ...seriesObject,
89
+ emphasis: {
90
+ ...seriesObject?.emphasis,
91
+ itemStyle: {
92
+ borderColor: 'transparent',
93
+ color: 'transparent',
94
+ },
95
+ },
96
+ };
97
+ }
98
+ }
99
+
100
+ _parsePeakvalley(options, seriesObject);
101
+
102
+ _handleSeries(options, seriesObject, index);
103
+
104
+ return seriesObject;
105
+ },
106
+ );
107
+ }
108
+
109
+ if (
110
+ (Array.isArray(options.type) && options.type.includes('radar')) ||
111
+ options.type === 'radar'
112
+ )
113
+ parsedOptions.radar = options.radar;
114
+
115
+ // Modify yAxis for percentage display
116
+ if (options.percentage) {
117
+ parsedOptions.yAxis = {
118
+ ...parsedOptions.yAxis,
119
+ axisLabel: { formatter: '{value}%' },
120
+ max: 100,
121
+ };
122
+
123
+ parsedOptions.tooltip = {
124
+ trigger: 'axis',
125
+ formatter: percentageTooltipFormatter,
126
+ };
127
+ }
128
+
129
+ if (options.markArea || options.markLine) {
130
+ parsedOptions.tooltip = {
131
+ trigger: 'axis',
132
+ axisPointer: {
133
+ type: 'cross',
134
+ },
135
+ };
136
+ }
137
+
138
+ if (options.waterfall) {
139
+ parsedOptions.legend = {
140
+ ...parsedOptions.legend,
141
+ data: parsedOptions.series
142
+ .map((series) => series.name)
143
+ .filter((name) => name !== 'Placeholder'),
144
+ };
145
+ parsedOptions.xAxis = {
146
+ ...parsedOptions.xAxis,
147
+ splitLine: { show: false },
148
+ };
149
+
150
+ parsedOptions.tooltip = {
151
+ trigger: 'axis',
152
+ axisPointer: {
153
+ type: 'shadow',
154
+ },
155
+ formatter: function (params) {
156
+ var tar = params[1];
157
+ return (
158
+ tar.name +
159
+ '<br/>' +
160
+ tar.marker +
161
+ tar.seriesName +
162
+ ' : ' +
163
+ tar.value
164
+ );
165
+ },
166
+ };
167
+ }
168
+
169
+ return parsedOptions;
170
+ };
171
+
172
+ export default _parser_data;
173
+
174
+ export function percentageTooltipFormatter(params) {
175
+ let total = params.reduce((sum, item) => sum + item.value, 0);
176
+ let tooltipContent = params
177
+ .map((item) => {
178
+ let percentage = ((item.value / total) * 100).toFixed(2);
179
+ return `${item.marker}${item.seriesName}: ${percentage}%`;
180
+ })
181
+ .join('<br/>');
182
+ return `${params[0].axisValueLabel}<br/>${tooltipContent}`;
183
+ }
@@ -0,0 +1,125 @@
1
+ /*
2
+ * @Author : Lihao leolihao@arizona.edu
3
+ * @Date : 2023-12-03 13:01:48
4
+ * @FilePath : /visualifyjs/src/core/parser/echart.features.js
5
+ * @Description :
6
+ * Copyright (c) 2023 by Lihao (leolihao@arizona.edu), All Rights Reserved.
7
+ */
8
+
9
+ export function _parsePeakvalley(options, seriesObject) {
10
+ if (options.valley || options.peak) {
11
+ seriesObject.markPoint = {};
12
+ seriesObject.markPoint.data = [];
13
+ if (options.peak) {
14
+ seriesObject.markPoint.data.push({
15
+ type: 'max',
16
+ name: 'Max',
17
+ label: {
18
+ formatter:
19
+ typeof options.peak === 'string' ? options.peak : 'Max',
20
+ },
21
+ });
22
+ }
23
+ if (options.valley) {
24
+ seriesObject.markPoint.data.push({
25
+ type: 'min',
26
+ name: 'Min',
27
+ label: {
28
+ formatter:
29
+ typeof options.valley === 'string'
30
+ ? options.valley
31
+ : 'Min',
32
+ },
33
+ });
34
+ }
35
+ }
36
+ }
37
+
38
+ export function _parseMarkArea(markAreaOption, seriesIndex) {
39
+ const markAreaOptions = {};
40
+
41
+ const formatAreaData = (option) => {
42
+ let areas = [];
43
+
44
+ const processAxis = (axisData, axisName) => {
45
+ if (Array.isArray(axisData)) {
46
+ axisData.forEach((data) =>
47
+ areas.push([
48
+ { [axisName]: data.start, name: data.name },
49
+ { [axisName]: data.end },
50
+ ]),
51
+ );
52
+ } else {
53
+ areas.push([
54
+ { [axisName]: axisData.start, name: axisData.name },
55
+ { [axisName]: axisData.end },
56
+ ]);
57
+ }
58
+ };
59
+
60
+ if (option.xAxis) {
61
+ processAxis(option.xAxis, 'xAxis');
62
+ }
63
+ if (option.yAxis) {
64
+ processAxis(option.yAxis, 'yAxis');
65
+ }
66
+
67
+ return areas;
68
+ };
69
+
70
+ let areaData = [];
71
+ let selectedOption =
72
+ Array.isArray(markAreaOption) && seriesIndex < markAreaOption.length
73
+ ? markAreaOption[seriesIndex]
74
+ : markAreaOption;
75
+
76
+ areaData = formatAreaData(selectedOption);
77
+ markAreaOptions.data = areaData;
78
+
79
+ // Add emphasis and other additional properties
80
+ Object.keys(selectedOption).forEach((key) => {
81
+ if (key === 'data') {
82
+ markAreaOptions[key] = markAreaOptions[key].concat(
83
+ selectedOption[key],
84
+ );
85
+ } else if (key !== 'xAxis' && key !== 'yAxis') {
86
+ markAreaOptions[key] = selectedOption[key];
87
+ }
88
+ });
89
+
90
+ return markAreaOptions;
91
+ }
92
+
93
+ export function _parseMarkLine(markLineOption, seriesIndex) {
94
+ const markLineOptions = {};
95
+
96
+ let selectedOption =
97
+ Array.isArray(markLineOption) && seriesIndex < markLineOption.length
98
+ ? markLineOption[seriesIndex]
99
+ : markLineOption;
100
+
101
+ markLineOptions.emphasis = {
102
+ lineStyle: {
103
+ width: 5,
104
+ type: 'solid',
105
+ },
106
+ };
107
+
108
+ markLineOptions.blur = {
109
+ lineStyle: {
110
+ opacity: 0.5, // Example blur style
111
+ },
112
+ };
113
+
114
+ markLineOptions.lineStyle = {
115
+ type: 'dashed', // 'solid','dashed'
116
+ width: 3,
117
+ };
118
+
119
+ // Add additional properties from markLineOption
120
+ Object.keys(selectedOption).forEach((key) => {
121
+ markLineOptions[key] = selectedOption[key];
122
+ });
123
+
124
+ return markLineOptions;
125
+ }
@@ -0,0 +1,147 @@
1
+ /*
2
+ * @Author : Lihao leolihao@arizona.edu
3
+ * @Date : 2023-12-02 11:56:41
4
+ * @FilePath : /visualify.js/src/core/parser/echart.general.js
5
+ * @Description :
6
+ *
7
+ * Copyright (c) 2023 by Lihao (leolihao@arizona.edu), All Rights Reserved.
8
+ */
9
+ import { handle_alltypes_chart } from './echart.types';
10
+ import { getArrayEl } from './echart.series';
11
+
12
+ const _parser_gereral = (options = {}, preset = {}) => {
13
+ // Parse the custom options
14
+ const parsedOptions = handle_alltypes_chart(getArrayEl(options.type), {
15
+ ...preset,
16
+ });
17
+
18
+ // Parse the common options
19
+ if ('title' in options) {
20
+ if (typeof options.title === 'string')
21
+ parsedOptions.title = {
22
+ ...parsedOptions?.title,
23
+ text: options.title,
24
+ };
25
+ else parsedOptions.title = options.title;
26
+ }
27
+
28
+ if ('subtitle' in options) parsedOptions.title.subtext = options.subtitle;
29
+
30
+ if (options.legend === false) parsedOptions.legend = { show: false };
31
+ else if ('legend' in options)
32
+ parsedOptions.legend = { ...options.legend, ...options.legend };
33
+
34
+ if ('xAxis' in options) {
35
+ if (options.xAxis === false) parsedOptions.xAxis = { show: false };
36
+ else if (Array.isArray(options.xAxis)) {
37
+ parsedOptions.xAxis = {
38
+ ...parsedOptions?.xAxis,
39
+ data: options.xAxis,
40
+ };
41
+ } else {
42
+ parsedOptions.xAxis = options.xAxis;
43
+ }
44
+ }
45
+
46
+ if ('yAxis' in options) {
47
+ if (options.yAxis === false) parsedOptions.yAxis = { show: false };
48
+ else if (Array.isArray(options.yAxis))
49
+ parsedOptions.yAxis = {
50
+ ...parsedOptions?.yAxis,
51
+ data: options.yAxis,
52
+ };
53
+ else parsedOptions.yAxis = options.yAxis;
54
+ }
55
+
56
+ if ('xAxisLabel' in options) {
57
+ parsedOptions.xAxis = {
58
+ ...parsedOptions?.xAxis,
59
+ name: options.xAxisLabel,
60
+ };
61
+ }
62
+
63
+ if ('yAxisLabel' in options) {
64
+ parsedOptions.yAxis = {
65
+ ...parsedOptions?.yAxis,
66
+ name: options.yAxisLabel,
67
+ };
68
+ }
69
+
70
+ if ('xAxisLineshow' in options) {
71
+ parsedOptions.xAxis = {
72
+ ...parsedOptions?.xAxis,
73
+ axisLine: {
74
+ ...parsedOptions.xAxis?.axisLine,
75
+ show: options.xAxisLineshow,
76
+ },
77
+ };
78
+ }
79
+
80
+ if ('yAxisLineshow' in options) {
81
+ parsedOptions.yAxis = {
82
+ ...parsedOptions?.yAxis,
83
+ axisLine: {
84
+ ...parsedOptions.yAxis?.axisLine,
85
+ show: options.yAxisLineshow,
86
+ },
87
+ };
88
+ }
89
+
90
+ if ('xAxisLabelShow' in options) {
91
+ parsedOptions.xAxis = {
92
+ ...parsedOptions?.xAxis,
93
+ axisLabel: {
94
+ ...parsedOptions.xAxis?.axisLabel,
95
+ show: options.xAxisLabelShow,
96
+ },
97
+ };
98
+ }
99
+
100
+ if ('yAxisLabelShow' in options) {
101
+ parsedOptions.yAxis = {
102
+ ...parsedOptions.yAxis,
103
+ axisLabel: {
104
+ ...parsedOptions.yAxis?.axisLabel,
105
+ show: options.yAxisLabelShow,
106
+ },
107
+ };
108
+ }
109
+
110
+ if ('xAxisLabelColor' in options) {
111
+ parsedOptions.xAxis = {
112
+ ...parsedOptions?.xAxis, // Copy existing xAxis properties
113
+ axisLabel: {
114
+ ...parsedOptions.xAxis?.axisLabel, // Copy existing axisLabel properties
115
+ color: options.xAxisLabelColor,
116
+ },
117
+ };
118
+ }
119
+
120
+ if ('yAxisLabelColor' in options) {
121
+ parsedOptions.yAxis = {
122
+ ...parsedOptions?.yAxis, // Copy existing yAxis properties
123
+ axisLabel: {
124
+ ...parsedOptions.yAxis?.axisLabel, // Copy existing axisLabel properties
125
+ color: options.yAxisLabelColor,
126
+ },
127
+ };
128
+ }
129
+
130
+ if ('tooltip' in options) {
131
+ parsedOptions.tooltip = {
132
+ ...parsedOptions?.tooltip,
133
+ ...options.tooltip,
134
+ };
135
+ }
136
+
137
+ if ('toolbox' in options) {
138
+ parsedOptions.toolbox = {
139
+ ...parsedOptions?.toolbox,
140
+ ...options.toolbox,
141
+ };
142
+ }
143
+
144
+ return parsedOptions;
145
+ };
146
+
147
+ export default _parser_gereral;