2 lines
2.5 KiB
JavaScript
2 lines
2.5 KiB
JavaScript
import{t as F,l as d,z as v,D as c,Q as x,T as p,ap as _,br as b}from"./index-CEmnTf-r.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,h=i.labelField,l=h===void 0?"label":h,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,h=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 h("chart",{type:"chart"},{config:l,chartRef:this.chartRef})},c([x,p("design:type",Function),p("design:paramtypes",[Object]),p("design:returntype",void 0)],e.prototype,"chartRef",null),c([_(),p("design:type",Function),p("design:paramtypes",[]),p("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};
|