realchart-vue
Version:
Wooritech realchart vue component library
67 lines (66 loc) • 1.63 kB
JavaScript
import { ref as s, onMounted as h, defineComponent as f, useAttrs as m, computed as p, toRaw as C, onUnmounted as y, createElementBlock as _, openBlock as v, normalizeStyle as g } from "vue";
function R({
realchartModule: c,
elRef: l,
config: e,
animate: u = !0,
onChartLoaded: i
}) {
const a = s(null), n = s(!1), o = (t) => {
const r = c.createChart(
document,
l.value,
t,
u,
i
);
return a.value = r, r;
};
return h(() => {
n.value || !l.value || (n.value = !0, o(e));
}), { realChart: a };
}
const k = ["id"], w = /* @__PURE__ */ f({
__name: "RealChart",
props: {
realchart: {},
id: { default: "realchart" },
w: {},
h: {},
config: {},
animate: { type: Boolean, default: !0 },
onChartLoaded: {}
},
setup(c, { expose: l }) {
const e = c, u = m(), i = p(() => ({
width: e.w,
height: e.h,
...u.style
})), a = s(null), { realChart: n } = R({
elRef: a,
realchartModule: e.realchart,
config: o(C(e.config)),
animate: e.animate,
onChartLoaded: e.onChartLoaded
});
l({
realchart: n
});
function o(t) {
return Array.isArray(t) ? t.map(o).filter((r) => r != null) : t && typeof t == "object" ? Object.fromEntries(
Object.entries(t).filter(([, r]) => r != null).map(([r, d]) => [r, o(d)])
) : t;
}
return y(() => {
n.value?._obj.destroy();
}), (t, r) => (v(), _("div", {
id: e.id,
ref_key: "elRef",
ref: a,
style: g(i.value)
}, null, 12, k));
}
}), x = w;
export {
x as RealChartVue
};