javascript - Apache Echarts 和 Vue-ECharts - 饼图动画在加载时不起作用
问题描述
我有一个工作正常的简单甜甜圈/饼图,但我无法获得默认动画或任何动画工作。
我正在使用 laravel 8、vuejs 2 和 echarts / vue-echarts。
这是我在 /resopurces/js/components/popular-brands-chart.vue 中的 vue 组件
<template>
<v-chart class="chart" :option="option" autoresize />
</template>
<script>
import { use } from "echarts/core";
import { CanvasRenderer } from "echarts/renderers";
import { PieChart } from "echarts/charts";
import { TitleComponent, TooltipComponent, LegendComponent } from "echarts/components";
import VChart from "vue-echarts";
use([CanvasRenderer, PieChart, TitleComponent, TooltipComponent, LegendComponent]);
export default {
name: "mostpopularbrands",
components: {
VChart,
},
data() {
return {
option: {
animation: true,
backgroundColor: "#fefefe",
color: ["#AD5BA3", "#4EC0B1", "#F4A620", "#EE5969", "#528DCA"],
textStyle: {
fontFamily: "museo-sans",
fontWeight: "bold",
},
label: {
show: true,
color: "#fff",
},
tooltip: {
trigger: "item",
formatter: "{a} <br/>{b} : {c} ({d}%)",
},
legend: {
orient: "vertical",
right: "15%",
top: "13%",
data: ["Titleist", "TaylorMade", "Callaway", "Ping", "Nike"],
icon: "circle",
padding: [5, 5],
itemGap: 15,
textStyle: {
fontFamily: "museo-sans",
fontWeight: "normal",
color: "#4C4C4C",
fontSize: "15",
},
},
series: [
{
name: "Most popular brands",
type: "pie",
animationType: "expansion",
animationDuration: 5000,
animationDurationUpdate: 500,
startAngle: 0,
endAngle: 360,
radius: [30, 95],
center: ["25%", "36%"],
label: {
formatter: function (d = "{d}") {
let rounderPercent = Math.round(d.percent);
return rounderPercent + "%";
},
position: "inside",
show: true,
},
data: [
{ value: 170, name: "Titleist" },
{ value: 100, name: "TaylorMade" },
{ value: 75, name: "Callaway" },
{ value: 50, name: "Ping" },
{ value: 37, name: "Nike" },
],
itemStyle: {
borderColor: "#fff",
borderWidth: 2,
},
},
],
},
};
},
};
</script>
<style scoped>
.chart {
margin-top: 2rem;
height: 300px;
width: 100%;
}
</style>
在 bootstrap.js文件中,我也添加了它,但很确定它目前没有做任何事情,即使我使用 vue 3 示例导入它也没有任何效果。
/* VueCompositionAPI */
import VueCompositionAPI from '@vue/composition-api'
Vue.use(VueCompositionAPI)
从技术上讲,我不应该做任何事情来让它动画,没有控制台错误。这是它应该做什么的参考: https ://echarts.apache.org/examples/en/editor.html?c=pie-doughnut
我实际上可以通过 CDN 和 codepen 在这里工作,为什么它工作,我不知道: https ://codepen.io/marcgaumont/pen/OJWyZwe
这是用于 vue 的包: https ://github.com/ecomfe/vue-echarts
一切正常,但经过 10 多个小时试图让它动画化,尝试了每一个例子。我完全不走运。
有任何想法吗 ?
解决方案
推荐阅读
- serialization - 无法在 Kotlin 中序列化对象单例
- c++ - vkCreateGraphicsPipelines 上的读取访问冲突
- apache-kafka - Alpakka Akka Stream 无法从 kafka 读取
- https - 使用代理服务器读取 HTTPS 流量
- wordpress - 如何修复 WordPress 中的“错误加载块:无效参数:属性”错误
- python - 对于这个特定问题,我对如何用“re.sub”替换句子感到困惑
- scikit-learn - 集群算法的标签输出是否按特定顺序排序?(python、scikit 学习)
- java - 在 Java 中使用其他方法中的参数调用方法
- r - 为什么 R 3.6.0 在评估表达式 ("Dogs" < "cats") 时返回 FALSE?
- python - 如何在python中反序列化scala中的序列化对象