Skip to content

Commit 3e4615f

Browse files
committed
chore: improve demo
1 parent e224c49 commit 3e4615f

File tree

12 files changed

+163
-87
lines changed

12 files changed

+163
-87
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"comment-mark": "^1.1.1",
4545
"core-js": "^3.32.0",
4646
"echarts": "^5.4.3",
47+
"echarts-gl": "^2.0.9",
4748
"echarts-liquidfill": "^3.1.0",
4849
"eslint": "^7.32.0",
4950
"eslint-plugin-prettier": "^3.4.1",

pnpm-lock.yaml

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/demo/Demo.vue

Lines changed: 11 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<geo-chart />
2020
<radar-chart />
2121
<connect-chart />
22+
<gl-chart />
2223
<manual-chart />
2324

2425
<footer>
@@ -65,6 +66,7 @@ import ScatterChart from "./examples/ScatterChart";
6566
import GeoChart from "./examples/GeoChart";
6667
import RadarChart from "./examples/RadarChart";
6768
import ConnectChart from "./examples/ConnectChart";
69+
import GlChart from "./examples/GlChart";
6870
import ManualChart from "./examples/ManualChart";
6971
7072
use([CanvasRenderer, SVGRenderer]);
@@ -137,6 +139,7 @@ h2 {
137139
vertical-align: middle;
138140
}
139141
}
142+
140143
.desc {
141144
margin-bottom: 3em;
142145
color: #7f8c8d;
@@ -158,6 +161,7 @@ p small {
158161
p {
159162
line-height: 1.5;
160163
}
164+
161165
pre {
162166
display: inline-block;
163167
padding: 0.8em;
@@ -171,16 +175,6 @@ code {
171175
font-family: "Roboto Mono", Monaco, courier, monospace;
172176
}
173177
174-
pre code {
175-
font-size: 0.8em;
176-
}
177-
178-
.attr {
179-
color: #e96900;
180-
}
181-
.val {
182-
color: #42b983;
183-
}
184178
footer {
185179
margin: 5em 0 3em;
186180
font-size: 0.5em;
@@ -200,16 +194,16 @@ footer {
200194
border-bottom: 3px solid #42b983;
201195
}
202196
}
197+
203198
button,
204199
select {
205200
border: 1px solid #4fc08d;
206-
border-radius: 2em;
201+
border-radius: 0.5em;
207202
background-color: #fff;
208203
color: #42b983;
209204
cursor: pointer;
210205
font: inherit;
211206
padding: 0 0.5em;
212-
transition: opacity 0.3s;
213207
transition: all 0.2s;
214208
215209
&:focus {
@@ -228,33 +222,6 @@ select {
228222
opacity: 0.5;
229223
cursor: not-allowed;
230224
}
231-
232-
&.round {
233-
width: 1.6em;
234-
height: 1.6em;
235-
position: relative;
236-
237-
&::before,
238-
&::after {
239-
content: "";
240-
position: absolute;
241-
top: 50%;
242-
left: 50%;
243-
transform: translate(-50%, -50%);
244-
width: 9px;
245-
height: 1px;
246-
background-color: #42b983;
247-
}
248-
249-
&::after {
250-
width: 1px;
251-
height: 9px;
252-
}
253-
254-
&.expand::after {
255-
display: none;
256-
}
257-
}
258225
}
259226
260227
label {
@@ -276,7 +243,7 @@ button,
276243
label,
277244
select {
278245
font-size: 0.75em;
279-
height: 2.4em;
246+
height: 2em;
280247
}
281248
282249
figure {
@@ -369,9 +336,9 @@ figure {
369336
flex: 1 0;
370337
margin: 0 0.5em;
371338
padding: 0;
372-
line-height: 2.4em;
339+
line-height: 2em;
373340
max-width: 40vw;
374-
border-radius: 2px;
341+
border-radius: 0.5em;
375342
font-size: 0.8em;
376343
}
377344
@@ -384,6 +351,7 @@ figure {
384351
}
385352
}
386353
}
354+
387355
figure {
388356
width: 100vw;
389357
margin: 1em auto;
@@ -399,18 +367,16 @@ figure {
399367
}
400368
}
401369
}
370+
402371
.renderer {
403372
position: fixed;
404373
top: 10px;
405374
left: 10px;
406375
font-size: 16px;
407-
text-align: center;
408376
409377
button {
410-
float: left;
411378
position: relative;
412379
width: 64px;
413-
border-radius: 6px;
414380
border-color: #36485e;
415381
color: rgba(54, 72, 94, 0.8);
416382
font-weight: 500;

src/demo/assets/starfield.jpg

901 KB
Loading

src/demo/assets/world.jpg

1.25 MB
Loading

src/demo/data/logo.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
/* eslint-disable */
2-
import logo from '../assets/Vue-ECharts.svg'
3-
/* eslint-enable */
1+
import logo from "../assets/Vue-ECharts.svg";
42

53
const d = logo.match(/\bd="([^"]+)"/)[1];
64

src/demo/data/population.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

src/demo/examples/ConnectChart.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ watch(
3737
</script>
3838

3939
<template>
40-
<v-example id="connect" title="Connectable Charts" split>
40+
<v-example id="connect" title="Connectable charts" split>
4141
<template #start>
4242
<v-chart :option="c1" group="radiance" autoresize />
4343
</template>

src/demo/examples/Example.vue

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,10 @@
22
<h2 :id="id">
33
<a :href="`#${id}`">
44
{{ title }}
5-
<small v-if="desc"
6-
><slot v-if="$slots.desc" /><template v-else>{{
7-
desc
8-
}}</template></small
9-
>
5+
<small v-if="desc">{{ desc }}</small>
106
</a>
11-
<button
12-
class="round"
13-
:class="{ expand }"
14-
@click="expand = !expand"
15-
aria-label="toggle"
16-
></button>
177
</h2>
18-
<section v-if="expand">
8+
<section>
199
<figure v-if="!split">
2010
<slot />
2111
</figure>
@@ -31,25 +21,19 @@
3121
</section>
3222
</template>
3323

34-
<script>
35-
export default {
36-
name: "v-example",
37-
props: {
38-
id: {
39-
type: String,
40-
required: true
41-
},
42-
title: {
43-
type: String,
44-
required: true
45-
},
46-
desc: String,
47-
split: Boolean
24+
<script setup>
25+
import { defineProps } from "vue";
26+
27+
defineProps({
28+
id: {
29+
type: String,
30+
required: true
31+
},
32+
title: {
33+
type: String,
34+
required: true
4835
},
49-
data() {
50-
return {
51-
expand: true
52-
};
53-
}
54-
};
36+
desc: String,
37+
split: Boolean
38+
});
5539
</script>

src/demo/examples/GlChart.vue

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
<script setup>
2+
import { use } from "echarts/core";
3+
import { Bar3DChart } from "echarts-gl/charts";
4+
import { VisualMapComponent } from "echarts/components";
5+
import { GlobeComponent } from "echarts-gl/components";
6+
import { shallowRef, onMounted } from "vue";
7+
import VChart from "../../ECharts";
8+
import VExample from "./Example";
9+
import world from "../assets/world.jpg";
10+
import starfield from "../assets/starfield.jpg";
11+
12+
use([Bar3DChart, VisualMapComponent, GlobeComponent]);
13+
14+
const option = shallowRef();
15+
const loading = shallowRef(true);
16+
17+
const initOptions = {
18+
renderer: "canvas"
19+
};
20+
21+
const loadingOptions = {
22+
text: "Loading...",
23+
color: "#000",
24+
textColor: "#fff",
25+
maskColor: "transparent"
26+
};
27+
28+
onMounted(() => {
29+
import("../data/population.json").then(({ default: data }) => {
30+
loading.value = false;
31+
32+
data = data
33+
.filter(dataItem => dataItem[2] > 0)
34+
.map(dataItem => [dataItem[0], dataItem[1], Math.sqrt(dataItem[2])]);
35+
36+
option.value = {
37+
backgroundColor: "#000",
38+
globe: {
39+
baseTexture: world,
40+
heightTexture: world,
41+
shading: "lambert",
42+
environment: starfield,
43+
light: {
44+
main: {
45+
intensity: 2
46+
}
47+
},
48+
viewControl: {
49+
autoRotate: false
50+
}
51+
},
52+
visualMap: {
53+
max: 40,
54+
calculable: true,
55+
realtime: false,
56+
inRange: {
57+
colorLightness: [0.2, 0.9]
58+
},
59+
textStyle: {
60+
color: "#fff"
61+
},
62+
controller: {
63+
inRange: {
64+
color: "orange"
65+
}
66+
},
67+
outOfRange: {
68+
colorAlpha: 0
69+
}
70+
},
71+
series: [
72+
{
73+
type: "bar3D",
74+
coordinateSystem: "globe",
75+
data: data,
76+
barSize: 0.6,
77+
minHeight: 0.2,
78+
silent: true,
79+
itemStyle: {
80+
color: "orange"
81+
}
82+
}
83+
]
84+
};
85+
});
86+
});
87+
</script>
88+
89+
<template>
90+
<v-example id="gl" title="GL charts" desc="(Globe & Bar3D)">
91+
<v-chart
92+
:option="option"
93+
:init-options="initOptions"
94+
autoresize
95+
:loading="loading"
96+
:loading-options="loadingOptions"
97+
style="background-color: #000"
98+
/>
99+
<template #extra>
100+
<p>
101+
You can use extension packs like
102+
<a href="https://github.com/ecomfe/echarts-gl">ECharts-GL</a>.
103+
</p>
104+
<p>
105+
<small>(You can only use the canvas renderer for GL charts.)</small>
106+
</p>
107+
</template>
108+
</v-example>
109+
</template>

0 commit comments

Comments
 (0)