import{s as F,f as d,y as v,z as c,P as x,Q as h,aX as _,bk as b}from"./index-DT8qTvyx.js";var O=function(n){F(e,n);function e(){var t=n!==null&&n.apply(this,arguments)||this;return t.highlightIndex=-1,t.prevIndex=-1,t}return e.prototype.chartRef=function(t){var i=this,o;this.chart=t,(o=this.chart)===null||o===void 0||o.on("click","series",function(r){i.props.onToggle(i.props.options[r.dataIndex])}),setTimeout(function(){return i.highlight()})},e.prototype.highlight=function(t){t===void 0&&(t=this.highlightIndex),!this.props.static&&(this.highlightIndex=t,!(!this.chart||this.prevIndex===t)&&(~this.prevIndex&&this.chart.dispatchAction({type:"downplay",seriesIndex:0,dataIndex:this.prevIndex}),~t&&(this.chart.dispatchAction({type:"highlight",seriesIndex:0,dataIndex:t}),this.props.showTooltipOnHighlight&&this.chart.dispatchAction({type:"showTip",seriesIndex:0,dataIndex:t})),this.prevIndex=t))},e.prototype.componentDidMount=function(){this.props.selectedOptions.length&&this.highlight(this.props.options.indexOf(this.props.selectedOptions[0]))},e.prototype.componentDidUpdate=function(){this.props.selectedOptions.length&&this.highlight(this.props.options.indexOf(this.props.selectedOptions[0]))},e.prototype.renderStatic=function(t){t===void 0&&(t="-"),this.prevIndex=-1,this.highlightIndex=-1;var i=this.props,o=i.options,r=o===void 0?[]:o,s=i.selectedOptions,p=i.labelField,l=p===void 0?"label":p,a=i.valueField,u=a===void 0?"value":a,f=i.chartValueField;if(r.length&&s.length){var g=r.reduce(function(I,m){return I+m[f||u]},0);if(g>0){var y=(+s[0][f||u]/g*100).toFixed(2);t="".concat(s[0][l],"：").concat(y,"%")}}return d.createElement(d.Fragment,null,t)},e.prototype.render=function(){var t=this.props,i=t.options,o=t.labelField,r=t.chartValueField,s=t.valueField,p=t.render,l=v(v({legend:{top:10},tooltip:{formatter:function(a){return"".concat(a.name,"：").concat(a.value[r||s||"value"],"（").concat(a.percent,"%）")}},series:[{type:"pie",top:30,bottom:0}]},this.props.config),{dataset:{dimensions:[o||"label",r||s||"value"],source:i}});return p("chart",{type:"chart"},{config:l,chartRef:this.chartRef})},c([x,h("design:type",Function),h("design:paramtypes",[Object]),h("design:returntype",void 0)],e.prototype,"chartRef",null),c([_(),h("design:type",Function),h("design:paramtypes",[]),h("design:returntype",void 0)],e.prototype,"render",null),e}(d.Component),C=function(n){F(e,n);function e(){return n!==null&&n.apply(this,arguments)||this}return e.defaultProps={multiple:!1},e=c([b({type:"chart-radios",sizeMutable:!1})],e),e}(O);export{C as RadiosControlRenderer,O as default};
