@huyuchen/visual
Version:
## 组件环境
143 lines (142 loc) • 3.07 kB
JavaScript
import u from "../BaseChart/index.vue.js";
import i from "../BaseChart/config.js";
import { computed as s, toRefs as d, resolveComponent as m, openBlock as p, createBlock as y } from "vue";
import o from "lodash.merge";
import g from "../_virtual/_plugin-vue_export-helper.js";
const b = {
name: "HuPieChart",
components: {
BaseChart: u
},
props: {
data: {
type: [Object, Array],
default: () => ({})
},
/**
* [{name:'', data: [], ...}]
*/
series: {
type: Object,
default: () => ({})
},
tooltip: {
type: Object,
default: () => ({})
},
/**
* 图例配置
*/
legendOption: {
type: Object,
default: () => ({})
},
/**
* colors 自定义颜色
*/
colors: {
type: Array,
default: () => []
},
/**
* 饼图中间展示信息
*/
centerInfo: {
type: String,
default: ""
// {value|{d}}\n{name|{b}}
},
/**
* 饼图中间展示信息
*/
center: {
type: Array,
default: () => ["50%", "50%"]
// {value|{d}}\n{name|{b}}
},
name: {
type: String,
default: ""
},
innerRadius: {
type: [String, Number],
default: "40%"
},
outerRadius: {
type: [String, Number],
default: "70%"
},
isPie: {
type: Boolean,
default: !0
}
},
setup(e) {
const c = s(() => {
const t = l(), n = o(t, e.series);
return {
tooltip: o(
{
trigger: "item",
confine: !0
},
e.tooltip
),
legend: a(),
// config.legend(this.legendOption),
series: n,
color: o(e.colors, i.colors)
};
}), l = () => {
const t = e.isPie ? e.innerRadius : 0, n = !!e.centerInfo && e.isPie;
return {
name: e.name,
center: e.center,
type: "pie",
radius: [t, e.outerRadius],
avoidLabelOverlap: !1,
label: {
normal: i.normal(e.centerInfo, {
show: n,
textBorderWidth: 0,
color: "#ffffff"
})
},
emphasis: {
focus: !0,
// 是否淡出其他图形
label: {
show: n,
fontSize: "14",
color: "#fff",
fontWeight: "bold"
}
},
data: e.data
};
}, a = () => {
const t = function(r) {
return f(r);
}, n = o(e.legendOption, { formatter: t });
return i.legend(n);
}, f = (t) => {
if (Object.prototype.toString.call(e.data) === "[object Array]") {
const n = e.data.find((r) => r.name === t);
return n ? `${t}:${n.value}` : t;
} else
return t;
};
return {
...d(e),
option: c
};
}
};
function h(e, c, l, a, f, t) {
const n = m("base-chart");
return p(), y(n, { option: a.option }, null, 8, ["option"]);
}
const v = /* @__PURE__ */ g(b, [["render", h]]);
export {
v as default
};