123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291 |
- <template>
- <div ref="echartD" style="width: 100%; height: 100%; display: flex; justify-content: center"></div>
- </template>
- <script>
- import * as echarts from "echarts";
- export default {
- props: {
- dataMap: { type: Number, default: () => 0 },
- },
- data() {
- return {};
- },
- watch: {
- dataMap(val) {
- this.getData(val);
- },
- },
- mounted() {
- this.getData();
- },
- methods: {
- getData() {
- let echartsMap = this.$echarts.getInstanceByDom(this.$refs.echartD);
- if (echartsMap == null) {
- echartsMap = this.$echarts.init(this.$refs.echartD);
- }
- echartsMap.setOption({
- title: {
- show: true,
- text: "水源完好率",
- left: "center",
- right: "center",
- bottom: "center",
- top: "52%",
- center: 20,
- textStyle: {
- color: "#FFF",
- fontSize: "0.225rem",
- align: "center",
- fontFamily: "syhtN",
- },
- },
- series: [
- {
- name: "刻度",
- type: "gauge",
- radius: "80%",
- min: 0, //最小刻度
- max: 100, //最大刻度
- startAngle: 225, //开始角度 左侧角度
- endAngle: -135, //结束角度 右侧
- z: 4,
- splitNumber: 10,
- axisLine: {
- show: true,
- lineStyle: {
- width: 1,
- color: [[1, "rgba(0,0,0,0)"]],
- },
- }, //仪表盘轴线
- axisLabel: {
- show: false,
- color: "#00faff",
- fontSize: 14,
- distance: 20,
- formatter: function (v) {
- return v;
- },
- }, //刻度标签。
- axisTick: {
- show: true,
- splitNumber: 6,
- lineStyle: {
- color: "#00faff",
- width: 1,
- // length:10
- },
- length: 5,
- }, //刻度样式
- splitLine: {
- show: true,
- length: -10,
- lineStyle: {
- color: "#00faff",
- width: 1,
- },
- }, //分隔线样式
- },
- {
- type: "gauge",
- radius: "60%",
- // center: ["50%","70%"],
- splitNumber: 5, //刻度数量
- startAngle: 225, //开始角度 左侧角度
- endAngle: -135, //结束角度 右侧
- z: 4,
- axisLine: {
- show: true,
- roundCap: true,
- lineStyle: {
- width: 10,
- color: [
- [
- this.dataMap > 1 ? 1 : this.dataMap,
- new echarts.graphic.LinearGradient(0, 0, 1, 0, [
- { offset: 0, color: "#0099ff" },
- { offset: 1, color: "#00d5ff" },
- ]),
- ],
- // [1, "#111F42"],
- ],
- },
- },
- //分隔线样式。
- splitLine: {
- show: false,
- },
- axisLabel: {
- show: false,
- },
- axisTick: {
- show: false,
- },
- pointer: {
- show: false,
- length: "70%",
- width: "2%",
- },
- title: {
- show: false,
- offsetCenter: [0, 0], // x, y,单位px
- // textStyle: {
- // fontWeight: "100",
- // color: "#0ab7ff",
- // fontSize: 30,
- // },
- },
- //仪表盘详情,用于显示数据。
- detail: {
- show: true,
- offsetCenter: [0, "-20%"],
- color: "#ffffff",
- fontSize: "0.625rem",
- color: "#FFF",
- fontWeight: "500",
- fontFamily: "syhtN",
- formatter: function (v) {
- return v * 100 + "%";
- },
- },
- data: [
- {
- value: this.dataMap,
- },
- ],
- },
- {
- //内圆
- type: "pie",
- radius: "46%",
- center: ["50%", "50%"],
- z: 3,
- itemStyle: {
- color: new echarts.graphic.RadialGradient(
- 0.5,
- 0.5,
- 0.8,
- [
- {
- offset: 0,
- color: "#00b8f8",
- },
- {
- offset: 0.5,
- color: "#0068d4",
- },
- {
- offset: 1,
- color: "#0068d3",
- },
- ],
- false
- ),
- label: {
- show: false,
- },
- labelLine: {
- show: false,
- },
- },
- emphasis:{scale: 0.1},
- label: {
- show: false,
- },
- tooltip: {
- show: false,
- },
- data: [100],
- },
- // 刻度圈
- {
- type: "pie",
- radius: ["0%", "90%"],
- center: ["50%", "50%"],
- avoidLabelOverlap: false,
- z: 3,
- label: {
- show: false,
- position: "center",
- },
- itemStyle: {
- color: {
- type: "linear",
- x: 0,
- y: 0,
- x2: 0,
- y2: 1,
- colorStops: [
- {
- offset: 0,
- color: "#122c7a",
- },
- {
- offset: 1,
- color: "#122c7a",
- },
- ],
- },
- },
- labelLine: {
- show: false,
- },
- data: [
- {
- value: 100,
- },
- ],
- },
- //最外层圈
- {
- type: "pie",
- radius: ["0%", "100%"],
- center: ["50%", "50%"],
- avoidLabelOverlap: false,
- z: 2,
- emphasis:{scale: 0.1},
- label: {
- show: false,
- position: "center",
- },
- itemStyle: {
- color: {
- type: "linear",
- x: 0,
- y: 0,
- x2: 0,
- y2: 1,
- colorStops: [
- {
- offset: 0,
- color: "#0b1f61",
- },
- {
- offset: 1,
- color: "#0b1f61",
- },
- ],
- },
- },
- labelLine: {
- show: false,
- },
- data: [
- {
- value: 100,
- },
- ],
- },
- ],
- });
- window.onresize = function () {
- echartsMap.resize();
- };
- },
-
- },
- };
- </script>
- <style scoped></style>
|