欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vue-cli3+echarts實(shí)現(xiàn)漸變色儀表盤組件封裝

 更新時(shí)間:2022年03月27日 15:21:56   作者:不說(shuō)別的就是很菜  
這篇文章主要為大家詳細(xì)介紹了vue-cli3+echarts實(shí)現(xiàn)漸變色儀表盤組件封裝,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了vue-cli3+echarts實(shí)現(xiàn)封裝一個(gè)漸變色儀表盤組件,供大家參考,具體內(nèi)容如下

效果預(yù)覽

思路

1、使用兩個(gè)儀表盤疊加,起始角度一樣,底部?jī)x表盤結(jié)束角度固定不變
2、通過(guò)props傳入數(shù)據(jù)
3、計(jì)算在上層的儀表盤的結(jié)束角度并賦值

代碼

<template>
? <div class="gauge">
? ? <div class="gauge__bottom" ref="bottomGauge"></div>
? ? <div class="gauge__top" ref="topGauge"></div>
? ? <div class="gauge__label">數(shù)據(jù)占比</div>
? ? <div class="gauge__title">{{ this.gaugeData.gaugeTitle }}</div>
? </div>
</template>

<script>
import echarts from "echarts";
export default {
? name: "gauge",
? props: ["gaugeData"],//傳入的數(shù)據(jù)
? data() {
? ? return {
? ? ? bottomOption: {
? ? ? ? series: [
? ? ? ? ? {
? ? ? ? ? ? name: "",
? ? ? ? ? ? type: "gauge",
? ? ? ? ? ? startAngle: "225",
? ? ? ? ? ? endAngle: "-45",
? ? ? ? ? ? data: [{ value: 100, name: "" }],
? ? ? ? ? ? splitNumber: 10,
? ? ? ? ? ? detail: {
? ? ? ? ? ? ? show: false,
? ? ? ? ? ? },
? ? ? ? ? ? splitLine: {
? ? ? ? ? ? ? show: false,
? ? ? ? ? ? },
? ? ? ? ? ? pointer: {
? ? ? ? ? ? ? show: false,
? ? ? ? ? ? },
? ? ? ? ? ? axisTick: {
? ? ? ? ? ? ? show: false,
? ? ? ? ? ? },
? ? ? ? ? ? axisLabel: { show: false },
? ? ? ? ? ? axisLine: {
? ? ? ? ? ? ? lineStyle: {
? ? ? ? ? ? ? ? width: 10,
? ? ? ? ? ? ? ? color: [
? ? ? ? ? ? ? ? ? [
? ? ? ? ? ? ? ? ? ? 1,
? ? ? ? ? ? ? ? ? ? new echarts.graphic.LinearGradient(0, 0, 1, 0, [
? ? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? offset: 0,
? ? ? ? ? ? ? ? ? ? ? ? // 起始顏色
? ? ? ? ? ? ? ? ? ? ? ? color: "#707089",
? ? ? ? ? ? ? ? ? ? ? },
? ? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? offset: 1,
? ? ? ? ? ? ? ? ? ? ? ? // 結(jié)束顏色
? ? ? ? ? ? ? ? ? ? ? ? color: "#707089",
? ? ? ? ? ? ? ? ? ? ? },
? ? ? ? ? ? ? ? ? ? ]),
? ? ? ? ? ? ? ? ? ],
? ? ? ? ? ? ? ? ],
? ? ? ? ? ? ? },
? ? ? ? ? ? },
? ? ? ? ? },
? ? ? ? ],
? ? ? },
? ? ? topOption: {
? ? ? ? series: [
? ? ? ? ? {
? ? ? ? ? ? name: "業(yè)務(wù)指標(biāo)",
? ? ? ? ? ? type: "gauge",
? ? ? ? ? ? startAngle: "225",
? ? ? ? ? ? endAngle: "",
? ? ? ? ? ? detail: {
? ? ? ? ? ? ? formatter: "{value}%",
? ? ? ? ? ? ? color: "#01F9FF",
? ? ? ? ? ? ? fontSize: 18,
? ? ? ? ? ? ? fontFamily: "ZhenyanGB-Regular",
? ? ? ? ? ? ? offsetCenter: [0, 0],
? ? ? ? ? ? },
? ? ? ? ? ? data: [{ value: "", name: "" }],
? ? ? ? ? ? splitNumber: 10,
? ? ? ? ? ? splitLine: {
? ? ? ? ? ? ? show: false,
? ? ? ? ? ? },
? ? ? ? ? ? pointer: {
? ? ? ? ? ? ? show: false,
? ? ? ? ? ? },
? ? ? ? ? ? axisTick: {
? ? ? ? ? ? ? show: false,
? ? ? ? ? ? },
? ? ? ? ? ? axisLabel: { show: false },
? ? ? ? ? ? axisLine: {
? ? ? ? ? ? ? lineStyle: {
? ? ? ? ? ? ? ? width: 10,
? ? ? ? ? ? ? ? color: "",
? ? ? ? ? ? ? },
? ? ? ? ? ? },
? ? ? ? ? },
? ? ? ? ],
? ? ? },
? ? };
? },
? mounted() {
? ? this.getTopGauge();
? ? this.getBottomGauge();
? },
? methods: {
? ? getTopGauge() {
? ? ? const chart = this.$refs.topGauge;
? ? ? if (chart) {
? ? ? ? const myChart = this.$echarts.init(chart, null, { renderer: "svg" });
? ? ? ? this.$once("hook:beforeDestroy", function () {
? ? ? ? ? echarts.dispose(myChart);
? ? ? ? });
? ? ? ? this.topOption.series[0].data[0].value = this.gaugeData.gaugePercent;
? ? ? ? this.topOption.series[0].axisLine.lineStyle.color = this.gaugeData.guageColor;
? ? ? ? let tmp = 225 - 270 * (this.gaugeData.gaugePercent / 100);
? ? ? ? this.topOption.series[0].endAngle = tmp;
? ? ? ? const option = this.topOption;
? ? ? ? myChart.setOption(option);
? ? ? }
? ? },
? ? getBottomGauge() {
? ? ? const chart = this.$refs.bottomGauge;
? ? ? if (chart) {
? ? ? ? const myChart = this.$echarts.init(chart, null, { renderer: "svg" });
? ? ? ? this.$once("hook:beforeDestroy", function () {
? ? ? ? ? echarts.dispose(myChart);
? ? ? ? });
? ? ? ? const option = this.bottomOption;
? ? ? ? myChart.setOption(option);
? ? ? }
? ? },
? },
};
</script>

<style lang="less">
.gauge {
? width: 150px;
? height: 165px;
? position: relative;
? &__top {
? ? position: absolute;
? ? top: 0;
? ? left: 0;
? ? width: 100%;
? ? height: 150px;
? }
? &__bottom {
? ? position: absolute;
? ? top: 0;
? ? left: 0;
? ? width: 100%;
? ? height: 150px;
? }
? &__label {
? ? position: absolute;
? ? height: 21px;
? ? width: 64px;
? ? background: #0547c9;
? ? border: 1px solid #1e92ff;
? ? border-radius: 11.5px;
? ? border-radius: 11.5px;
? ? bottom: 35px;
? ? left: 50%;
? ? transform: translate(-50%, 0);
? ? font-family: PingFangSC-Regular;
? ? font-size: 8px;
? ? color: #ffffff;
? ? text-align: center;
? ? line-height: 21px;
? }
? &__title {
? ? font-family: PingFangSC-Medium;
? ? font-size: 14px;
? ? color: #52f9cb;
? ? text-align: center;
? ? position: absolute;
? ? bottom: 5px;
? ? left: 50%;
? ? transform: translate(-50%, 0);
? }
}
</style>

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • el-table渲染慢卡頓問(wèn)題最優(yōu)解決方案

    el-table渲染慢卡頓問(wèn)題最優(yōu)解決方案

    本文主要介紹了el-table渲染慢卡頓問(wèn)題最優(yōu)解決方案,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2022-08-08
  • element中一個(gè)單選框radio時(shí)的選中和取消代碼詳解

    element中一個(gè)單選框radio時(shí)的選中和取消代碼詳解

    這篇文章主要給大家介紹了關(guān)于element中一個(gè)單選框radio時(shí)的選中和取消的相關(guān)資料,文中通過(guò)圖文以及代碼示例介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考價(jià)值,需要的朋友可以參考下
    2023-09-09
  • vue3自定義插件的作用場(chǎng)景及使用示例詳解

    vue3自定義插件的作用場(chǎng)景及使用示例詳解

    這篇文章主要為大家介紹了vue3自定義插件的作用場(chǎng)景及使用示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-02-02
  • Vue this.$router.push(參數(shù))實(shí)現(xiàn)頁(yè)面跳轉(zhuǎn)操作

    Vue this.$router.push(參數(shù))實(shí)現(xiàn)頁(yè)面跳轉(zhuǎn)操作

    這篇文章主要介紹了Vue this.$router.push(參數(shù))實(shí)現(xiàn)頁(yè)面跳轉(zhuǎn)操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2020-09-09
  • 圖文講解用vue-cli腳手架創(chuàng)建vue項(xiàng)目步驟

    圖文講解用vue-cli腳手架創(chuàng)建vue項(xiàng)目步驟

    本次小編給大家?guī)?lái)的是關(guān)于用vue-cli腳手架創(chuàng)建vue項(xiàng)目步驟講解內(nèi)容,有需要的朋友們可以學(xué)習(xí)下。
    2019-02-02
  • 使用provide/inject實(shí)現(xiàn)跨組件通信的方法

    使用provide/inject實(shí)現(xiàn)跨組件通信的方法

    在 Vue 應(yīng)用中,組件間通信是構(gòu)建復(fù)雜應(yīng)用時(shí)的一個(gè)常見(jiàn)需求,Vue3.x 提供了provide和inject API,讓跨組件通信變得更加簡(jiǎn)潔和高效,本文將深入探討如何使用provide和inject在Vue3.x中實(shí)現(xiàn)跨組件通信,并通過(guò)示例代碼一步步進(jìn)行說(shuō)明,需要的朋友可以參考下
    2024-03-03
  • ElementPlus表格中的背景透明解決方案

    ElementPlus表格中的背景透明解決方案

    最近寫大屏,用到elementplus中的el-table,為了讓顯示效果好看一點(diǎn),需要把表格的白色背景調(diào)整為透明,與整個(gè)背景融為一體,本文給大家介紹ElementPlus表格中的背景透明解決方案,感興趣的朋友一起看看吧
    2023-10-10
  • Vue組件生命周期三個(gè)階段全面總結(jié)講解

    Vue組件生命周期三個(gè)階段全面總結(jié)講解

    Vue的生命周期就是vue實(shí)例從創(chuàng)建到銷毀的全過(guò)程,也就是new Vue() 開(kāi)始就是vue生命周期的開(kāi)始。Vue 實(shí)例有?個(gè)完整的?命周期,也就是從開(kāi)始創(chuàng)建、初始化數(shù)據(jù)、編譯模版、掛載Dom -> 渲染、更新 -> 渲染、卸載 等?系列過(guò)程,稱這是Vue的?命周期
    2022-11-11
  • Vue computed 計(jì)算屬性代碼實(shí)例

    Vue computed 計(jì)算屬性代碼實(shí)例

    在本篇文章里小編給大家分享的是關(guān)于Vue computed 計(jì)算屬性代碼實(shí)例,需要的朋友們可以參考下。
    2020-04-04
  • vue中的事件修飾符once,prevent,stop,capture,self,passive

    vue中的事件修飾符once,prevent,stop,capture,self,passive

    這篇文章主要介紹了vue中的事件修飾符once,prevent,stop,capture,self,passive,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-04-04

最新評(píng)論