最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

VUE動(dòng)態(tài)排序柱狀圖

2022-03-21 15:00 作者:丘奇小怪  | 我要投稿

1、新建項(xiàng)目,下載echarts

npm install echarts@4.9.0

2、修改helloworld.vue

修改template:

? <div class="echart" id="mychart" :style="myChartStyle"></div>


修改script:

import * as echarts from "echarts";


export default {

? data() {

? ? return {

? ? ? myChart: {},

? ? ? sortData: [], //動(dòng)態(tài)排序數(shù)據(jù)

? ? ? myChartStyle: { float: "left", width: "100%", height: "400px" }, //圖表樣式

? ? ? dynamicSortZZTOption: {

? ? ? ? xAxis: {

? ? ? ? ? max: "dataMax"

? ? ? ? },

? ? ? ? yAxis: {

? ? ? ? ? type: "category",

? ? ? ? ? data: ["A", "B", "C", "D", "E"],

? ? ? ? ? inverse: true,

? ? ? ? ? animationDuration: 300,

? ? ? ? ? animationDurationUpdate: 300,

? ? ? ? ? max: 4 // only the largest 3 bars will be displayed

? ? ? ? },

? ? ? ? series: [

? ? ? ? ? {

? ? ? ? ? ? realtimeSort: true,

? ? ? ? ? ? name: "動(dòng)態(tài)變化",

? ? ? ? ? ? type: "bar",

? ? ? ? ? ? data: [],

? ? ? ? ? ? label: {

? ? ? ? ? ? ? show: true,

? ? ? ? ? ? ? position: "right",

? ? ? ? ? ? ? valueAnimation: true

? ? ? ? ? ? }

? ? ? ? ? }

? ? ? ? ],

? ? ? ? legend: {

? ? ? ? ? show: true

? ? ? ? },

? ? ? ? animationDuration: 3000,

? ? ? ? animationDurationUpdate: 3000,

? ? ? ? animationEasing: "linear",

? ? ? ? animationEasingUpdate: "linear"

? ? ? }

? ? };

? },

? mounted() {

? ? // 圖表初始化

? ? this.myChart = echarts.init(document.getElementById("mychart"));

? ? // 數(shù)據(jù)初始化

? ? for (let i = 0; i < 5; ++i) {

? ? ? this.sortData.push(Math.round(Math.random() * 200));

? ? }

? ? // 數(shù)據(jù)刷新

? ? setInterval(() => {

? ? ? this.pageUpdate();

? ? }, 3000);

? },

? methods: {

? ? // 數(shù)據(jù)刷新

? ? pageUpdate() {

? ? ? console.log(this.dynamicSortZZTOption.series[0].data);

? ? ? this.dynamicSortZZTOption.series[0].data = this.sortData;

? ? ? for (let i = 0; i < this.sortData.length; ++i) {

? ? ? ? if (Math.random() > 0.9) {

? ? ? ? ? this.sortData[i] += Math.round(Math.random() * 2000);

? ? ? ? } else {

? ? ? ? ? this.sortData[i] += Math.round(Math.random() * 200);

? ? ? ? }

? ? ? }

? ? ? this.myChart.setOption(this.dynamicSortZZTOption);

? ? ? //隨著屏幕大小調(diào)節(jié)圖表

? ? ? window.addEventListener("resize", () => {

? ? ? ? this.myChart.resize();

? ? ? });

? ? }

? }

};

刪除style即可。

吐槽:b站檢測(cè)到j(luò)s居然會(huì)警告環(huán)境異常無法提交。。。


VUE動(dòng)態(tài)排序柱狀圖的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國家法律
承德市| 舒兰市| 临清市| 永宁县| 怀柔区| 澄城县| 巫溪县| 莱州市| 安图县| 新源县| 正阳县| 南宁市| 射阳县| 保亭| 西平县| 安龙县| 崇仁县| 鹿泉市| 丰都县| 马关县| 姜堰市| 榕江县| 沭阳县| 黎平县| 思南县| 太谷县| 永顺县| 高雄县| 临安市| 抚顺市| 保康县| 永靖县| 阿荣旗| 兴化市| 南皮县| 襄城县| 綦江县| 长武县| 乌鲁木齐县| 新龙县| 南木林县|