@zhsz/cool-design-dv
Version:
126 lines (125 loc) • 3.31 kB
JavaScript
;
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const vue = require("vue");
const useMyChart = require("../hooks/useMyChart.js");
const cartesian2d = require("../utils/cartesian2d.js");
const constant = require("../utils/constant.js");
const lodashEs = require("lodash-es");
const __default__ = vue.defineComponent({
name: "MyChartBar"
});
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
...__default__,
props: {
// 宽度
width: {
type: String,
default: "auto"
},
// 高度
height: {
type: String,
default: "400px"
},
// 适应父容器
fit: Boolean,
// ECharts 配置选项
options: {
type: Object
},
// 扩展 options
extend: [Object, Function],
// 主题
theme: {
type: [String, Object],
default() {
return constant.DEFAULT_THEME;
}
},
// 显示加载动画
loading: Boolean,
// 打印 options
debug: {
type: Boolean
},
// 图表私有设置
settings: {
type: Object,
default() {
return {};
}
},
// 图表数据 echarts dataset
data: {
type: [Object, Array],
default() {
return {};
}
},
// 地图名称
map: String,
// 地图geojson对象或构建函数,函数必须返回Promise
register: [Object, Function],
// 地图注册成功回调
onRegister: Function,
// 坐标集合 如:{'广州': [120.3234, 33.4329]}, 或 [{label:'广州',value: [120.3234, 33.4329]}]
coords: {
type: [Object, Array],
default() {
return {};
}
},
// 排列方向,即类别在哪个轴上
direction: {
type: String,
default: "x",
validator(val) {
return ["x", "y"].includes(val);
}
},
// 数据项的标签设置,字符类型设置position, 对象与原生series.label设置一致
label: [String, Object, Array],
// 值类型轴配置
valueAxis: [String, Object, Array],
// 堆叠柱,如 ['name1', 'name2'] 或 {'name': ['name1', 'name2']}
stack: [Object, Array],
// 改成柱状图显示的系列
bars: [String, Array],
// 线条平滑,只对折线图有效
smooth: {
type: [Boolean, Number],
default: 0.5
}
},
emits: ["register"],
setup(__props, { emit: __emit }) {
var _a;
const props = __props;
const instance = (_a = vue.getCurrentInstance()) == null ? void 0 : _a.proxy;
const $listeners = lodashEs.pickBy(vue.useAttrs(), lodashEs.isFunction);
const emits = __emit;
const adapter = (vm) => {
return cartesian2d.default(vm, "line", props);
};
const { registerMap, init, dispose, classes, styles } = useMyChart.default(
props,
instance,
$listeners,
emits,
adapter
);
vue.onMounted(() => {
registerMap().then(init);
});
vue.onBeforeUnmount(() => {
dispose();
});
return (_ctx, _cache) => {
return vue.openBlock(), vue.createElementBlock("div", {
class: vue.normalizeClass(vue.unref(classes)),
style: vue.normalizeStyle(vue.unref(styles))
}, null, 6);
};
}
});
exports.default = _sfc_main;