UNPKG

vue-data-ui-hq

Version:

A user-empowering data visualization Vue 3 components library for eloquent data storytelling

2 lines (1 loc) 2.11 kB
"use strict";const t=require("vue"),m=require("./index-ZfICPrrM.cjs"),c=["cx","cy","r","fill","stroke","stroke-width"],f=["d","fill","stroke","stroke-width"],p=["points","fill","stroke","stroke-width"],v={__name:"Shape",props:{color:String,isSelected:{type:Boolean,default:!1},limit:{type:Number,default:3},plot:Object,radius:Number,shape:String,stroke:String,strokeWidth:Number,zoom:{type:Number,default:1.3}},emits:["mouseover","mouseout","click"],setup(n,{emit:d}){const o=n,r=d;function k(u){return{circle:{points:1,rotation:0},line:{points:2,rotation:0},triangle:{points:3,rotation:.52},square:{points:4,rotation:.783},diamond:{points:4,rotation:0},pentagon:{points:5,rotation:.95},hexagon:{points:6,rotation:0}}[u]}const s=t.computed(()=>k(o.shape)),l=t.computed(()=>o.shape!=="star"?null:m.createStar({plot:{x:o.plot.x,y:o.plot.y},radius:o.radius*(o.isSelected?o.zoom:1)})),a=t.computed(()=>m.createPolygonPath({plot:{x:o.plot.x,y:o.plot.y},radius:o.radius*(o.isSelected?o.zoom:1),sides:s.value.points,rotation:s.value.rotation}).path);return(u,e)=>(t.openBlock(),t.createElementBlock("g",null,[t.unref(s)&&t.unref(s).points===1?(t.openBlock(),t.createElementBlock("circle",{key:0,cx:n.plot.x,cy:n.plot.y,r:o.radius*(o.isSelected?o.zoom:1),fill:n.color,stroke:n.stroke,"stroke-width":n.strokeWidth,onMouseover:e[0]||(e[0]=i=>r("mouseover")),onMouseout:e[1]||(e[1]=i=>r("mouseout")),onClick:e[2]||(e[2]=i=>r("click"))},null,40,c)):t.createCommentVNode("",!0),t.unref(s)&&t.unref(s).points>=n.limit?(t.openBlock(),t.createElementBlock("path",{key:1,d:t.unref(a),fill:n.color,stroke:n.stroke,"stroke-width":n.strokeWidth,onMouseover:e[3]||(e[3]=i=>r("mouseover")),onMouseout:e[4]||(e[4]=i=>r("mouseout")),onClick:e[5]||(e[5]=i=>r("click"))},null,40,f)):t.createCommentVNode("",!0),t.unref(l)?(t.openBlock(),t.createElementBlock("polygon",{key:2,points:t.unref(l),fill:n.color,stroke:n.stroke,"stroke-width":n.strokeWidth,onMouseover:e[6]||(e[6]=i=>r("mouseover")),onMouseout:e[7]||(e[7]=i=>r("mouseout")),onClick:e[8]||(e[8]=i=>r("click"))},null,40,p)):t.createCommentVNode("",!0)]))}};exports._sfc_main=v;