visualifyjs 2.5.3-2.dev → 2.5.3-9-dev
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of visualifyjs might be problematic. Click here for more details.
- package/.github/workflows/{static.yml.bak → build.yaml} +51 -51
- package/LICENSE +674 -674
- package/README.md +40 -58
- package/config-overrides.js +31 -31
- package/dist/visualify.js +3 -3
- package/docs/CLI.md +15 -0
- package/docs/{docs/README.md → README.md} +41 -65
- package/docs/{docs/Rechart → Rechart}/bar.md +190 -190
- package/docs/{docs/Rechart → Rechart}/funnel.md +193 -241
- package/docs/{docs/Rechart → Rechart}/line.md +355 -355
- package/docs/{docs/Rechart → Rechart}/pie.md +225 -225
- package/docs/{docs/Rechart → Rechart}/radar.md +253 -253
- package/docs/{docs/_404.md → _404.md} +51 -51
- package/docs/{docs/_coverpage.md → _coverpage.md} +11 -11
- package/docs/{docs/_sidebar.md → _sidebar.md} +42 -44
- package/docs/{docs/components → components}/dotBio.md +34 -34
- package/docs/{docs/components → components}/echart.md +82 -82
- package/docs/{docs/components → components}/html.md +34 -34
- package/docs/{docs/components → components}/macaron.md +145 -145
- package/docs/components/markdown.md +0 -0
- package/docs/{docs/components → components}/more.md +142 -142
- package/docs/{docs/components → components}/plotly.md +62 -62
- package/docs/{docs/components → components}/scatterL.md +70 -70
- package/docs/{docs/components → components}/visium.md +56 -56
- package/docs/{docs/configuration.md → configuration.md} +123 -121
- package/docs/{docs/deploy.md → deploy.md} +23 -31
- package/docs/index.html +70 -70
- package/docs/log.md +1 -0
- package/docs/manifest.json +23 -23
- package/docs/{docs/more-pages.md → more-pages.md} +23 -23
- package/docs/{docs/quickstart.md → quickstart.md} +115 -124
- package/docs/{docs/rechart-attributes.md → rechart-attributes.md} +74 -74
- package/docs/{docs/rechart-basic-usage.md → rechart-basic-usage.md} +162 -162
- package/docs/static/css/fluff-stuff.css +169 -169
- package/docs/static/css/font-awesome.min.css +4 -4
- package/docs/static/css/visualify.css +25 -25
- package/docs/static/js/configuration.js +448 -448
- package/docs/static/js/visualify.js +24 -23
- package/docs/theme.md +3 -0
- package/package.json +74 -83
- package/rollup.config.mjs +75 -75
- package/src/_css/404.css +115 -115
- package/src/_css/App.css +37 -37
- package/src/_css/autoSuggestion.css +26 -26
- package/src/_css/circular-progress.css +32 -32
- package/src/_css/index.css +36 -36
- package/src/_css/modern.css +24 -24
- package/src/_media/corner.svg +8 -8
- package/src/_media/download.svg +3 -3
- package/src/_media/logo.svg +14 -14
- package/src/_test/App.test.js +15 -15
- package/src/_utils/reportWebVitals.js +13 -13
- package/src/core/appContext.js +27 -27
- package/src/core/components/Scatter.js +188 -188
- package/src/core/components/ScatterBio.js +572 -572
- package/src/core/components/VisiumPlot.js +165 -165
- package/src/core/components/browser.js +42 -42
- package/src/core/components/dotplot.js +413 -413
- package/src/core/components/html.js +29 -29
- package/src/core/components/list.js +178 -178
- package/src/core/components/macaron.js +201 -201
- package/src/core/components/markdown.js +56 -56
- package/src/core/components/parser.scatterBio.js +579 -587
- package/src/core/components/ratio.js +80 -80
- package/src/core/components/scatterL.js +173 -173
- package/src/core/components/searchbar.js +131 -131
- package/src/core/components/selection.js +193 -193
- package/src/core/components/timeline.js +281 -281
- package/src/core/components/visium.js +97 -97
- package/src/core/fetch/condfetch.js +82 -82
- package/src/core/fetch/fetch.js +92 -92
- package/src/core/fetch/json.js +29 -29
- package/src/core/fetch/vfetch.js +42 -42
- package/src/core/liveEditor.js +44 -44
- package/src/core/modules/codeEditorWithPreview.js +104 -104
- package/src/core/modules/echarts/common.js +20 -20
- package/src/core/modules/echarts/presetHandler.js +41 -41
- package/src/core/modules/echarts/presets/esodev.chromium.js +172 -172
- package/src/core/modules/echarts/presets/esodev.codex.js +130 -130
- package/src/core/modules/echarts/presets/esodev.visium.js +123 -123
- package/src/core/modules/echarts/presets/mmtrbc.js +186 -186
- package/src/core/modules/echarts.js +71 -71
- package/src/core/modules/echartsUtils.js +43 -43
- package/src/core/modules/echartswitcher.js +152 -152
- package/src/core/modules/replotly/presetHandler.js +24 -24
- package/src/core/modules/replotly/presets/minimum.js +18 -18
- package/src/core/modules/replotly/presets/mmtrbc.dot.js +114 -114
- package/src/core/modules/replotly/presets/mmtrbc.violin.js +100 -100
- package/src/core/modules/replotly.js +71 -71
- package/src/core/pages/404.js +50 -50
- package/src/core/pages/error.js +27 -27
- package/src/core/pages/jsonPage.js +62 -62
- package/src/core/pages/loading.js +44 -44
- package/src/core/parser/echart.data.js +183 -183
- package/src/core/parser/echart.features.js +125 -125
- package/src/core/parser/echart.general.js +143 -147
- package/src/core/parser/echart.hilbert.js +57 -57
- package/src/core/parser/echart.parser.js +210 -210
- package/src/core/parser/echart.series.js +67 -67
- package/src/core/parser/echart.types.js +76 -76
- package/src/core/parser/plotly.config.js +10 -10
- package/src/core/parser/plotly.data.js +132 -132
- package/src/core/parser/plotly.layout.js +9 -9
- package/src/core/parser/plotly.violin.js +18 -18
- package/src/core/recharts.js +62 -62
- package/src/core/router/alias.js +49 -49
- package/src/core/router/jsonRouter.js +31 -31
- package/src/core/themes/modern.js +32 -32
- package/src/core/themes/themeSelector.js +33 -33
- package/src/core/visualify.js +47 -47
- package/src/core/widgets/circularProgress.js +23 -23
- package/src/core/widgets/controller.js +83 -83
- package/src/core/widgets/errorBoundary.js +36 -36
- package/src/core/widgets/footer.js +177 -177
- package/src/core/widgets/header.js +234 -234
- package/src/core/widgets/layout/Grid.js +31 -31
- package/src/core/widgets/layout.js +36 -36
- package/src/core/widgets/mapping.js +42 -42
- package/src/index.js +62 -62
- package/src/setupTests.js +5 -5
- package/docs/docs/CLI.md +0 -34
- package/docs/docs/Rechart/scatter.md +0 -298
- package/docs/docs/log.md +0 -9
- package/docs/docs/static/logo/favicon.ico +0 -0
- package/docs/docs/static/logo/logo_128x128.png +0 -0
- package/docs/docs/static/logo/logo_192x192.png +0 -0
- package/docs/docs/static/logo/logo_256x256.png +0 -0
- package/docs/docs/static/logo/logo_512x512.png +0 -0
- package/docs/docs/static/logo/logo_64x64.png +0 -0
- package/docs/docs/theme.md +0 -5
- /package/docs/{docs/Rechart → Rechart}/geo.md +0 -0
- /package/docs/{docs/Rechart → Rechart}/liquidfill.md +0 -0
- /package/docs/{docs/Rechart → Rechart}/polar.md +0 -0
- /package/docs/{docs/Rechart → Rechart}/sankey.md +0 -0
- /package/docs/{docs/Rechart/sunburst.md → Rechart/scatter.md} +0 -0
- /package/docs/{docs/Rechart/tree.md → Rechart/sunburst.md} +0 -0
- /package/docs/{docs/Rechart/wordcloud.md → Rechart/tree.md} +0 -0
- /package/docs/{docs/components/markdown.md → Rechart/wordcloud.md} +0 -0
- /package/docs/{docs/static → static}/_images/deploy-github-pages.png +0 -0
@@ -1,210 +1,210 @@
|
|
1
|
-
/*
|
2
|
-
* @Author : Lihao leolihao@arizona.edu
|
3
|
-
* @Date : 2023-12-23 23:27:45
|
4
|
-
* @FilePath : /visualifyjs/src/core/parser/echart.parser.js
|
5
|
-
* @Description :
|
6
|
-
* Copyright (c) 2023 by Lihao (leolihao@arizona.edu), All Rights Reserved.
|
7
|
-
*/
|
8
|
-
import conditionalFetch from '../fetch/condfetch';
|
9
|
-
import { isEmpty } from 'lodash';
|
10
|
-
|
11
|
-
const enableVisualMap = (series) => {
|
12
|
-
if (!series || series.length === 0) return false;
|
13
|
-
const seriesData = series[0].data;
|
14
|
-
if (!seriesData) return false;
|
15
|
-
// Check if the series data has z values (indicating 3D data)
|
16
|
-
return seriesData.some((dataPoint) => dataPoint.value.length === 3);
|
17
|
-
};
|
18
|
-
|
19
|
-
const _fetch_data = async (parser = {}, Options = {}, sharedData) => {
|
20
|
-
const { sources } = parser;
|
21
|
-
|
22
|
-
let fetched_data = {}; // response from api
|
23
|
-
|
24
|
-
const processSource = async (source) => {
|
25
|
-
let resp = await conditionalFetch(
|
26
|
-
source,
|
27
|
-
sharedData,
|
28
|
-
Options.title,
|
29
|
-
Options.visualify,
|
30
|
-
);
|
31
|
-
if (resp) fetched_data[source.name] = resp;
|
32
|
-
};
|
33
|
-
|
34
|
-
if (Array.isArray(sources)) {
|
35
|
-
await Promise.all(sources.map(processSource));
|
36
|
-
} else if (typeof sources === 'object') {
|
37
|
-
await processSource(sources);
|
38
|
-
}
|
39
|
-
|
40
|
-
if (isEmpty(fetched_data))
|
41
|
-
throw new Error(parser?.startup_msg ?? 'No data fetched from api');
|
42
|
-
|
43
|
-
return fetched_data;
|
44
|
-
};
|
45
|
-
|
46
|
-
export const _process_fetched_data = (
|
47
|
-
fetched_data,
|
48
|
-
parser = {},
|
49
|
-
Options = {},
|
50
|
-
) => {
|
51
|
-
Options.series = __process_fetched_data(
|
52
|
-
fetched_data,
|
53
|
-
parser,
|
54
|
-
Options.visualify,
|
55
|
-
);
|
56
|
-
Options.legend.data = Options.series.map((item) => item.name);
|
57
|
-
|
58
|
-
if (!enableVisualMap(Options.series)) {
|
59
|
-
//console.log('disable visual map');
|
60
|
-
Options.visualMap = [];
|
61
|
-
}
|
62
|
-
return Options;
|
63
|
-
};
|
64
|
-
|
65
|
-
const __process_fetched_data = (
|
66
|
-
fetched_data,
|
67
|
-
parser_config,
|
68
|
-
visualify = {},
|
69
|
-
) => {
|
70
|
-
//console.log('visualify', visualify);
|
71
|
-
const {
|
72
|
-
seriesBy = visualify?.seriesBy ?? null,
|
73
|
-
mapping = visualify?.mapping ?? {},
|
74
|
-
exclude = visualify?.exclude ?? [],
|
75
|
-
symbol = visualify?.symbol ?? null,
|
76
|
-
symbolSize = visualify?.symbolSize ?? null,
|
77
|
-
merger = visualify?.merger ?? null,
|
78
|
-
filter = visualify?.filter ?? null,
|
79
|
-
} = parser_config;
|
80
|
-
const { x = 'x', y = 'y', z = 'z', extra = [] } = mapping;
|
81
|
-
const aggregatedData = {};
|
82
|
-
|
83
|
-
for (const [key, data] of Object.entries(fetched_data)) {
|
84
|
-
//console.log('processing data from api', key, data);
|
85
|
-
if (!data) {
|
86
|
-
return Object.values(aggregatedData);
|
87
|
-
} else if (data && merger && merger[key]) {
|
88
|
-
/*
|
89
|
-
console.log(
|
90
|
-
`processing data from merger:`,
|
91
|
-
key,
|
92
|
-
`merger`,
|
93
|
-
merger[key],
|
94
|
-
`data`,
|
95
|
-
data,
|
96
|
-
`with`,
|
97
|
-
aggregatedData,
|
98
|
-
);
|
99
|
-
*/
|
100
|
-
// add extra properties to aggregatedData.data
|
101
|
-
Object.values(aggregatedData).forEach((item) => {
|
102
|
-
item.data.forEach((value) => {
|
103
|
-
if (merger[key].item in value) {
|
104
|
-
let tag = value[merger[key].item];
|
105
|
-
let val = data[tag];
|
106
|
-
if (merger[key].label) value[merger[key].label] = val;
|
107
|
-
if (merger[key].visualMap) value.value.push(val);
|
108
|
-
}
|
109
|
-
});
|
110
|
-
});
|
111
|
-
} else {
|
112
|
-
// if seriesBy is not defined, get the first key of data as the series
|
113
|
-
const seriesKey = seriesBy ?? Object.keys(data)[0];
|
114
|
-
|
115
|
-
if (data[seriesKey] === undefined || data === undefined) continue;
|
116
|
-
data[seriesKey].forEach((item, index) => {
|
117
|
-
if (exclude && exclude.includes(item)) return;
|
118
|
-
|
119
|
-
const extraProperties = {};
|
120
|
-
for (const property in mapping.extra) {
|
121
|
-
if (data[extra[property]]) {
|
122
|
-
extraProperties[property] =
|
123
|
-
data[extra[property]][index];
|
124
|
-
}
|
125
|
-
}
|
126
|
-
|
127
|
-
if (!data[x] || !data[y] || !parser_config.type) return;
|
128
|
-
|
129
|
-
const point = data[z]
|
130
|
-
? [data[x][index], data[y][index], data[z][index]]
|
131
|
-
: [data[x][index], data[y][index]];
|
132
|
-
|
133
|
-
if (!aggregatedData[item]) {
|
134
|
-
aggregatedData[item] = {
|
135
|
-
name: item,
|
136
|
-
type: parser_config.type,
|
137
|
-
data: [],
|
138
|
-
};
|
139
|
-
if (symbol) aggregatedData[item].symbol = symbol;
|
140
|
-
if (symbolSize)
|
141
|
-
aggregatedData[item].symbolSize = symbolSize;
|
142
|
-
}
|
143
|
-
|
144
|
-
aggregatedData[item].data.push({
|
145
|
-
value: point,
|
146
|
-
...extraProperties,
|
147
|
-
});
|
148
|
-
});
|
149
|
-
}
|
150
|
-
}
|
151
|
-
|
152
|
-
let processed_data = Object.values(aggregatedData);
|
153
|
-
|
154
|
-
if (filter) {
|
155
|
-
for (let filter_key of Object.keys(filter)) {
|
156
|
-
const filter_expression = filter[filter_key];
|
157
|
-
//console.log('filter', filter_key, filter_expression);
|
158
|
-
processed_data = processed_data.map((item) => {
|
159
|
-
const filteredData = item.data.filter((dataPoint) => {
|
160
|
-
try {
|
161
|
-
const value = dataPoint[filter_key];
|
162
|
-
if (value === undefined || value === null) return true;
|
163
|
-
|
164
|
-
const match =
|
165
|
-
filter_expression.match(/([><]=?)\s*(-?\d+)/);
|
166
|
-
if (!match)
|
167
|
-
throw new Error(
|
168
|
-
'Invalid filter expression for filter',
|
169
|
-
);
|
170
|
-
|
171
|
-
// Extract the operator and threshold value
|
172
|
-
const operator = match[1];
|
173
|
-
const threshold = parseInt(match[2]);
|
174
|
-
// Evaluate the filter expression using the function
|
175
|
-
return eval_filter(value, operator, threshold);
|
176
|
-
} catch (err) {
|
177
|
-
console.warn('error in filter', err);
|
178
|
-
return false;
|
179
|
-
}
|
180
|
-
});
|
181
|
-
return {
|
182
|
-
...item,
|
183
|
-
data: filteredData,
|
184
|
-
};
|
185
|
-
});
|
186
|
-
}
|
187
|
-
}
|
188
|
-
|
189
|
-
return processed_data;
|
190
|
-
};
|
191
|
-
|
192
|
-
// Define a function to evaluate filter expressions
|
193
|
-
function eval_filter(value, operator, threshold) {
|
194
|
-
switch (operator) {
|
195
|
-
case '<':
|
196
|
-
return value < threshold;
|
197
|
-
case '<=':
|
198
|
-
return value <= threshold;
|
199
|
-
case '>':
|
200
|
-
return value > threshold;
|
201
|
-
case '>=':
|
202
|
-
return value >= threshold;
|
203
|
-
case '=':
|
204
|
-
return value === threshold;
|
205
|
-
default:
|
206
|
-
throw new Error('Invalid operator in filter expression');
|
207
|
-
}
|
208
|
-
}
|
209
|
-
|
210
|
-
export default _fetch_data;
|
1
|
+
/*
|
2
|
+
* @Author : Lihao leolihao@arizona.edu
|
3
|
+
* @Date : 2023-12-23 23:27:45
|
4
|
+
* @FilePath : /visualifyjs/src/core/parser/echart.parser.js
|
5
|
+
* @Description :
|
6
|
+
* Copyright (c) 2023 by Lihao (leolihao@arizona.edu), All Rights Reserved.
|
7
|
+
*/
|
8
|
+
import conditionalFetch from '../fetch/condfetch';
|
9
|
+
import { isEmpty } from 'lodash';
|
10
|
+
|
11
|
+
const enableVisualMap = (series) => {
|
12
|
+
if (!series || series.length === 0) return false;
|
13
|
+
const seriesData = series[0].data;
|
14
|
+
if (!seriesData) return false;
|
15
|
+
// Check if the series data has z values (indicating 3D data)
|
16
|
+
return seriesData.some((dataPoint) => dataPoint.value.length === 3);
|
17
|
+
};
|
18
|
+
|
19
|
+
const _fetch_data = async (parser = {}, Options = {}, sharedData) => {
|
20
|
+
const { sources } = parser;
|
21
|
+
|
22
|
+
let fetched_data = {}; // response from api
|
23
|
+
|
24
|
+
const processSource = async (source) => {
|
25
|
+
let resp = await conditionalFetch(
|
26
|
+
source,
|
27
|
+
sharedData,
|
28
|
+
Options.title,
|
29
|
+
Options.visualify,
|
30
|
+
);
|
31
|
+
if (resp) fetched_data[source.name] = resp;
|
32
|
+
};
|
33
|
+
|
34
|
+
if (Array.isArray(sources)) {
|
35
|
+
await Promise.all(sources.map(processSource));
|
36
|
+
} else if (typeof sources === 'object') {
|
37
|
+
await processSource(sources);
|
38
|
+
}
|
39
|
+
|
40
|
+
if (isEmpty(fetched_data))
|
41
|
+
throw new Error(parser?.startup_msg ?? 'No data fetched from api');
|
42
|
+
|
43
|
+
return fetched_data;
|
44
|
+
};
|
45
|
+
|
46
|
+
export const _process_fetched_data = (
|
47
|
+
fetched_data,
|
48
|
+
parser = {},
|
49
|
+
Options = {},
|
50
|
+
) => {
|
51
|
+
Options.series = __process_fetched_data(
|
52
|
+
fetched_data,
|
53
|
+
parser,
|
54
|
+
Options.visualify,
|
55
|
+
);
|
56
|
+
Options.legend.data = Options.series.map((item) => item.name);
|
57
|
+
|
58
|
+
if (!enableVisualMap(Options.series)) {
|
59
|
+
//console.log('disable visual map');
|
60
|
+
Options.visualMap = [];
|
61
|
+
}
|
62
|
+
return Options;
|
63
|
+
};
|
64
|
+
|
65
|
+
const __process_fetched_data = (
|
66
|
+
fetched_data,
|
67
|
+
parser_config,
|
68
|
+
visualify = {},
|
69
|
+
) => {
|
70
|
+
//console.log('visualify', visualify);
|
71
|
+
const {
|
72
|
+
seriesBy = visualify?.seriesBy ?? null,
|
73
|
+
mapping = visualify?.mapping ?? {},
|
74
|
+
exclude = visualify?.exclude ?? [],
|
75
|
+
symbol = visualify?.symbol ?? null,
|
76
|
+
symbolSize = visualify?.symbolSize ?? null,
|
77
|
+
merger = visualify?.merger ?? null,
|
78
|
+
filter = visualify?.filter ?? null,
|
79
|
+
} = parser_config;
|
80
|
+
const { x = 'x', y = 'y', z = 'z', extra = [] } = mapping;
|
81
|
+
const aggregatedData = {};
|
82
|
+
|
83
|
+
for (const [key, data] of Object.entries(fetched_data)) {
|
84
|
+
//console.log('processing data from api', key, data);
|
85
|
+
if (!data) {
|
86
|
+
return Object.values(aggregatedData);
|
87
|
+
} else if (data && merger && merger[key]) {
|
88
|
+
/*
|
89
|
+
console.log(
|
90
|
+
`processing data from merger:`,
|
91
|
+
key,
|
92
|
+
`merger`,
|
93
|
+
merger[key],
|
94
|
+
`data`,
|
95
|
+
data,
|
96
|
+
`with`,
|
97
|
+
aggregatedData,
|
98
|
+
);
|
99
|
+
*/
|
100
|
+
// add extra properties to aggregatedData.data
|
101
|
+
Object.values(aggregatedData).forEach((item) => {
|
102
|
+
item.data.forEach((value) => {
|
103
|
+
if (merger[key].item in value) {
|
104
|
+
let tag = value[merger[key].item];
|
105
|
+
let val = data[tag];
|
106
|
+
if (merger[key].label) value[merger[key].label] = val;
|
107
|
+
if (merger[key].visualMap) value.value.push(val);
|
108
|
+
}
|
109
|
+
});
|
110
|
+
});
|
111
|
+
} else {
|
112
|
+
// if seriesBy is not defined, get the first key of data as the series
|
113
|
+
const seriesKey = seriesBy ?? Object.keys(data)[0];
|
114
|
+
|
115
|
+
if (data[seriesKey] === undefined || data === undefined) continue;
|
116
|
+
data[seriesKey].forEach((item, index) => {
|
117
|
+
if (exclude && exclude.includes(item)) return;
|
118
|
+
|
119
|
+
const extraProperties = {};
|
120
|
+
for (const property in mapping.extra) {
|
121
|
+
if (data[extra[property]]) {
|
122
|
+
extraProperties[property] =
|
123
|
+
data[extra[property]][index];
|
124
|
+
}
|
125
|
+
}
|
126
|
+
|
127
|
+
if (!data[x] || !data[y] || !parser_config.type) return;
|
128
|
+
|
129
|
+
const point = data[z]
|
130
|
+
? [data[x][index], data[y][index], data[z][index]]
|
131
|
+
: [data[x][index], data[y][index]];
|
132
|
+
|
133
|
+
if (!aggregatedData[item]) {
|
134
|
+
aggregatedData[item] = {
|
135
|
+
name: item,
|
136
|
+
type: parser_config.type,
|
137
|
+
data: [],
|
138
|
+
};
|
139
|
+
if (symbol) aggregatedData[item].symbol = symbol;
|
140
|
+
if (symbolSize)
|
141
|
+
aggregatedData[item].symbolSize = symbolSize;
|
142
|
+
}
|
143
|
+
|
144
|
+
aggregatedData[item].data.push({
|
145
|
+
value: point,
|
146
|
+
...extraProperties,
|
147
|
+
});
|
148
|
+
});
|
149
|
+
}
|
150
|
+
}
|
151
|
+
|
152
|
+
let processed_data = Object.values(aggregatedData);
|
153
|
+
|
154
|
+
if (filter) {
|
155
|
+
for (let filter_key of Object.keys(filter)) {
|
156
|
+
const filter_expression = filter[filter_key];
|
157
|
+
//console.log('filter', filter_key, filter_expression);
|
158
|
+
processed_data = processed_data.map((item) => {
|
159
|
+
const filteredData = item.data.filter((dataPoint) => {
|
160
|
+
try {
|
161
|
+
const value = dataPoint[filter_key];
|
162
|
+
if (value === undefined || value === null) return true;
|
163
|
+
|
164
|
+
const match =
|
165
|
+
filter_expression.match(/([><]=?)\s*(-?\d+)/);
|
166
|
+
if (!match)
|
167
|
+
throw new Error(
|
168
|
+
'Invalid filter expression for filter',
|
169
|
+
);
|
170
|
+
|
171
|
+
// Extract the operator and threshold value
|
172
|
+
const operator = match[1];
|
173
|
+
const threshold = parseInt(match[2]);
|
174
|
+
// Evaluate the filter expression using the function
|
175
|
+
return eval_filter(value, operator, threshold);
|
176
|
+
} catch (err) {
|
177
|
+
console.warn('error in filter', err);
|
178
|
+
return false;
|
179
|
+
}
|
180
|
+
});
|
181
|
+
return {
|
182
|
+
...item,
|
183
|
+
data: filteredData,
|
184
|
+
};
|
185
|
+
});
|
186
|
+
}
|
187
|
+
}
|
188
|
+
|
189
|
+
return processed_data;
|
190
|
+
};
|
191
|
+
|
192
|
+
// Define a function to evaluate filter expressions
|
193
|
+
function eval_filter(value, operator, threshold) {
|
194
|
+
switch (operator) {
|
195
|
+
case '<':
|
196
|
+
return value < threshold;
|
197
|
+
case '<=':
|
198
|
+
return value <= threshold;
|
199
|
+
case '>':
|
200
|
+
return value > threshold;
|
201
|
+
case '>=':
|
202
|
+
return value >= threshold;
|
203
|
+
case '=':
|
204
|
+
return value === threshold;
|
205
|
+
default:
|
206
|
+
throw new Error('Invalid operator in filter expression');
|
207
|
+
}
|
208
|
+
}
|
209
|
+
|
210
|
+
export default _fetch_data;
|
@@ -1,67 +1,67 @@
|
|
1
|
-
/*
|
2
|
-
* @Author : Lihao leolihao@arizona.edu
|
3
|
-
* @Date : 2023-12-02 22:53:11
|
4
|
-
* @FilePath : /visualifyjs/src/core/parser/echart.series.js
|
5
|
-
* @Description :
|
6
|
-
* Copyright (c) 2023 by Lihao (leolihao@arizona.edu), All Rights Reserved.
|
7
|
-
*/
|
8
|
-
export function _handleSeries(options, seriesObject, index) {
|
9
|
-
setArrayEl(seriesObject, options, 'label', index);
|
10
|
-
setArrayEl(seriesObject, options, 'labelLine', index);
|
11
|
-
setArrayEl(seriesObject, options, 'itemStyle', index);
|
12
|
-
setArrayEl(seriesObject, options, 'emphasis', index);
|
13
|
-
// Handle Line Chart options
|
14
|
-
if (seriesObject.type === 'line') {
|
15
|
-
setArrayEl(seriesObject, options, 'smooth', index);
|
16
|
-
setArrayEl(seriesObject, options, 'step', index);
|
17
|
-
setArrayEl(seriesObject, options, 'areaStyle', index);
|
18
|
-
} else if (seriesObject.type === 'pie') {
|
19
|
-
setArrayEl(seriesObject, options, 'selectedMode', index);
|
20
|
-
setArrayEl(seriesObject, options, 'roseType', index);
|
21
|
-
if ('center' in options)
|
22
|
-
seriesObject.center = getArray(options.center, index);
|
23
|
-
if ('radius' in options)
|
24
|
-
seriesObject.radius = getArray(options.radius, index);
|
25
|
-
} else if (seriesObject.type === 'radar') {
|
26
|
-
if ('radar' in options && Array.isArray(options.radar))
|
27
|
-
seriesObject.radarIndex = index;
|
28
|
-
} else if (seriesObject.type === 'funnel') {
|
29
|
-
seriesObject.top = getArrayEl(options.top, index) ?? 60;
|
30
|
-
seriesObject.bottom = getArrayEl(options.bottom, index) ?? 60;
|
31
|
-
seriesObject.left = getArrayEl(options.left, index) ?? '10%';
|
32
|
-
setArrayEl(seriesObject, options, 'right', index);
|
33
|
-
seriesObject.width = getArrayEl(options.width, index) ?? '80%';
|
34
|
-
setArrayEl(seriesObject, options, 'height', index);
|
35
|
-
seriesObject.min = getArrayEl(options.min, index) ?? 0;
|
36
|
-
seriesObject.max = getArrayEl(options.max, index) ?? 100;
|
37
|
-
seriesObject.minSize = getArrayEl(options.minSize, index) ?? '0%';
|
38
|
-
seriesObject.maxSize = getArrayEl(options.maxSize, index) ?? '100%';
|
39
|
-
seriesObject.sort = getArrayEl(options.sort, index) ?? 'descending';
|
40
|
-
seriesObject.gap = getArrayEl(options.gap, index) ?? 0;
|
41
|
-
seriesObject.funnelAlign =
|
42
|
-
getArrayEl(options.funnelAlign, index) ?? 'center';
|
43
|
-
setArrayEl(seriesObject, options, 'z', index);
|
44
|
-
}
|
45
|
-
}
|
46
|
-
|
47
|
-
function setArrayEl(sereis, options, param, index) {
|
48
|
-
let val = getArrayEl(options[param], index);
|
49
|
-
if (param in options && val) sereis[param] = val;
|
50
|
-
}
|
51
|
-
|
52
|
-
// Helper function to get the type for each series
|
53
|
-
export function getArrayEl(value, index) {
|
54
|
-
return Array.isArray(value)
|
55
|
-
? value[Math.min(index, value.length - 1)]
|
56
|
-
: value;
|
57
|
-
}
|
58
|
-
|
59
|
-
function getArray(value, index) {
|
60
|
-
let _inedx = Math.min(index, value.length - 1);
|
61
|
-
if (Array.isArray(value) && Array.isArray(value[_inedx]))
|
62
|
-
return value[_inedx];
|
63
|
-
else if (Array.isArray(value)) return value;
|
64
|
-
else return getArrayEl(value, index);
|
65
|
-
}
|
66
|
-
|
67
|
-
export default _handleSeries;
|
1
|
+
/*
|
2
|
+
* @Author : Lihao leolihao@arizona.edu
|
3
|
+
* @Date : 2023-12-02 22:53:11
|
4
|
+
* @FilePath : /visualifyjs/src/core/parser/echart.series.js
|
5
|
+
* @Description :
|
6
|
+
* Copyright (c) 2023 by Lihao (leolihao@arizona.edu), All Rights Reserved.
|
7
|
+
*/
|
8
|
+
export function _handleSeries(options, seriesObject, index) {
|
9
|
+
setArrayEl(seriesObject, options, 'label', index);
|
10
|
+
setArrayEl(seriesObject, options, 'labelLine', index);
|
11
|
+
setArrayEl(seriesObject, options, 'itemStyle', index);
|
12
|
+
setArrayEl(seriesObject, options, 'emphasis', index);
|
13
|
+
// Handle Line Chart options
|
14
|
+
if (seriesObject.type === 'line') {
|
15
|
+
setArrayEl(seriesObject, options, 'smooth', index);
|
16
|
+
setArrayEl(seriesObject, options, 'step', index);
|
17
|
+
setArrayEl(seriesObject, options, 'areaStyle', index);
|
18
|
+
} else if (seriesObject.type === 'pie') {
|
19
|
+
setArrayEl(seriesObject, options, 'selectedMode', index);
|
20
|
+
setArrayEl(seriesObject, options, 'roseType', index);
|
21
|
+
if ('center' in options)
|
22
|
+
seriesObject.center = getArray(options.center, index);
|
23
|
+
if ('radius' in options)
|
24
|
+
seriesObject.radius = getArray(options.radius, index);
|
25
|
+
} else if (seriesObject.type === 'radar') {
|
26
|
+
if ('radar' in options && Array.isArray(options.radar))
|
27
|
+
seriesObject.radarIndex = index;
|
28
|
+
} else if (seriesObject.type === 'funnel') {
|
29
|
+
seriesObject.top = getArrayEl(options.top, index) ?? 60;
|
30
|
+
seriesObject.bottom = getArrayEl(options.bottom, index) ?? 60;
|
31
|
+
seriesObject.left = getArrayEl(options.left, index) ?? '10%';
|
32
|
+
setArrayEl(seriesObject, options, 'right', index);
|
33
|
+
seriesObject.width = getArrayEl(options.width, index) ?? '80%';
|
34
|
+
setArrayEl(seriesObject, options, 'height', index);
|
35
|
+
seriesObject.min = getArrayEl(options.min, index) ?? 0;
|
36
|
+
seriesObject.max = getArrayEl(options.max, index) ?? 100;
|
37
|
+
seriesObject.minSize = getArrayEl(options.minSize, index) ?? '0%';
|
38
|
+
seriesObject.maxSize = getArrayEl(options.maxSize, index) ?? '100%';
|
39
|
+
seriesObject.sort = getArrayEl(options.sort, index) ?? 'descending';
|
40
|
+
seriesObject.gap = getArrayEl(options.gap, index) ?? 0;
|
41
|
+
seriesObject.funnelAlign =
|
42
|
+
getArrayEl(options.funnelAlign, index) ?? 'center';
|
43
|
+
setArrayEl(seriesObject, options, 'z', index);
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
function setArrayEl(sereis, options, param, index) {
|
48
|
+
let val = getArrayEl(options[param], index);
|
49
|
+
if (param in options && val) sereis[param] = val;
|
50
|
+
}
|
51
|
+
|
52
|
+
// Helper function to get the type for each series
|
53
|
+
export function getArrayEl(value, index) {
|
54
|
+
return Array.isArray(value)
|
55
|
+
? value[Math.min(index, value.length - 1)]
|
56
|
+
: value;
|
57
|
+
}
|
58
|
+
|
59
|
+
function getArray(value, index) {
|
60
|
+
let _inedx = Math.min(index, value.length - 1);
|
61
|
+
if (Array.isArray(value) && Array.isArray(value[_inedx]))
|
62
|
+
return value[_inedx];
|
63
|
+
else if (Array.isArray(value)) return value;
|
64
|
+
else return getArrayEl(value, index);
|
65
|
+
}
|
66
|
+
|
67
|
+
export default _handleSeries;
|