UNPKG

@dfsj/echarts

Version:

专业的水文曲线组件或构造函数以及通用的echart二次封装图表

12 lines (10 loc) 2.73 kB
/** * * @dfsj/echarts: 专业的水文曲线组件或构造函数以及通用的echart二次封装图表 * 版本: v4.0.0-alpha.9 * 作者:yangbo <1747837358@qq.com> * 日期:2026-07-10 17:09:23 * * */ import{toConsumableArray as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import n,{CATEGORY as t}from"../../config.js";import{useECharts as r}from"../../hooks/useECharts.js";import i from"../../utils/assign.js";import{toMarks as o,toIndices as l}from"../../utils/render.js";import{complexMinMaxIndex as s,minimum as u,maximum as a}from"../../utils/tools.js";import{useStatistic as c}from"../../view/useStatistic.js";import{useTable as d}from"../../view/useTable.js";import{buildLegend as m}from"../../utils/assemble.js";import f from"./default.js";function v(v,p){var g,h=v?r(v):{},j=h.setOptions,y=void 0===j?null:j,S=h.echarts,x=void 0===S?null:S,b=h.getInstance,I=void 0===b?function(){return null}:b,O=h.container,A=void 0===O?null:O,C=d(),T=(C.open,C.close,C.props),k=C.toggleTable;T.container=A;var E=c(),M=(E.open,E.close,E.props),$=E.toggleStatistic,w=null!=p&&p.S?p.S:function(e,n,t){return t.$series.find(function(n){return n.$code&e.code})},F=null!=p&&p.M?p.M:function(e,t){return o(e,t,n.mark)},G=null!=p&&p.I?p.I:function(e,n){return l(e,n)},J=null!==(g=null==p?void 0:p.C)&&void 0!==g?g:f;return{createOptions:function(e){if(null==e)return null;var n=s(e,t.FLOW),r=s(e,t.STAGE);return{yAxis:[{layout:t.FLOW,name:"流量(m³/s)",min:function(e){return u(e,n)},max:function(e){return a(e,n)}},{layout:t.STAGE,name:"水位(m)",min:function(e){return u(e,r)},max:function(e){return a(e,r)}}]}},setOptions:y,echarts:x,getInstance:I,container:A,assemble:function(t,r){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:I();t=null!=t?t:{};var l=JSON.parse(JSON.stringify(t)),s=i({},J,r);if(null!=l){var u,a,c,d;if(T.value=l,T.chart=o,M.chart=o,M.value=l,(null==l||null===(u=l.filterCodes)||void 0===u?void 0:u.length)>0)l.dimensions=null==l||null===(d=l.dimensions)||void 0===d?void 0:d.filter(function(e){return!l.filterCodes.includes((null==e?void 0:e.code)||e)});s.dataset.source=l.source,s.series=null===(a=l.dimensions)||void 0===a?void 0:a.filter(function(e,n){return n}).map(function(e,n){var t={x:0,y:n+1},r=s.yAxis.findIndex(function(n){return n&&n.$layout&e.code});return i({yAxisIndex:r,encode:t,name:e.name,selected:e.selected},w(e,n,s))});var f=G(l,s);null!=f&&f.length&&(c=s.series).push.apply(c,e(f));var v=F(l,s);null!=v&&v.length&&s.series.push(i({data:v},n.mark.series));var p=m(s.series);s.legend.data=p.data,s.legend.selected=p.selected}return s},toSeries:w,toMarks:F,toIndices:G,toggleTable:k,toggleStatistic:$}}export{v as useHydrology};