-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdatart-pivot.iife.js
1 lines (1 loc) · 15 KB
/
datart-pivot.iife.js
1
(function(){"use strict";function e({dHelper:e}){return{mockData:{describe:"标准交叉表数据。",fields:{rows:["province","city"],columns:["type","sub_type"],values:["number"],valueInCols:true},meta:[{field:"number",name:"数量"},{field:"province",name:"省份"},{field:"city",name:"城市"},{field:"type",name:"类别"},{field:"sub_type",name:"子类别"}],data:[{number:7789,province:"浙江省",city:"杭州市",type:"家具",sub_type:"桌子"},{number:2367,province:"浙江省",city:"绍兴市",type:"家具",sub_type:"桌子"},{number:3877,province:"浙江省",city:"宁波市",type:"家具",sub_type:"桌子"},{number:4342,province:"浙江省",city:"舟山市",type:"家具",sub_type:"桌子"},{number:5343,province:"浙江省",city:"杭州市",type:"家具",sub_type:"沙发"},{number:632,province:"浙江省",city:"绍兴市",type:"家具",sub_type:"沙发"},{number:7234,province:"浙江省",city:"宁波市",type:"家具",sub_type:"沙发"},{number:834,province:"浙江省",city:"舟山市",type:"家具",sub_type:"沙发"},{number:945,province:"浙江省",city:"杭州市",type:"办公用品",sub_type:"笔"},{number:1304,province:"浙江省",city:"绍兴市",type:"办公用品",sub_type:"笔"},{number:1145,province:"浙江省",city:"宁波市",type:"办公用品",sub_type:"笔"},{number:1432,province:"浙江省",city:"舟山市",type:"办公用品",sub_type:"笔"},{number:1343,province:"浙江省",city:"杭州市",type:"办公用品",sub_type:"纸张"},{number:1354,province:"浙江省",city:"绍兴市",type:"办公用品",sub_type:"纸张"},{number:1523,province:"浙江省",city:"宁波市",type:"办公用品",sub_type:"纸张"},{number:1634,province:"浙江省",city:"舟山市",type:"办公用品",sub_type:"纸张"},{number:1723,province:"四川省",city:"成都市",type:"家具",sub_type:"桌子"},{number:1822,province:"四川省",city:"绵阳市",type:"家具",sub_type:"桌子"},{number:1943,province:"四川省",city:"南充市",type:"家具",sub_type:"桌子"},{number:2330,province:"四川省",city:"乐山市",type:"家具",sub_type:"桌子"},{number:2451,province:"四川省",city:"成都市",type:"家具",sub_type:"沙发"},{number:2244,province:"四川省",city:"绵阳市",type:"家具",sub_type:"沙发"},{number:2333,province:"四川省",city:"南充市",type:"家具",sub_type:"沙发"},{number:2445,province:"四川省",city:"乐山市",type:"家具",sub_type:"沙发"},{number:2335,province:"四川省",city:"成都市",type:"办公用品",sub_type:"笔"},{number:245,province:"四川省",city:"绵阳市",type:"办公用品",sub_type:"笔"},{number:2457,province:"四川省",city:"南充市",type:"办公用品",sub_type:"笔"},{number:2458,province:"四川省",city:"乐山市",type:"办公用品",sub_type:"笔"},{number:4004,province:"四川省",city:"成都市",type:"办公用品",sub_type:"纸张"},{number:3077,province:"四川省",city:"绵阳市",type:"办公用品",sub_type:"纸张"},{number:3551,province:"四川省",city:"南充市",type:"办公用品",sub_type:"纸张"},{number:352,province:"四川省",city:"乐山市",type:"办公用品",sub_type:"纸张"}],totalData:[{number:26193,type:"家具",sub_type:"桌子"},{number:49709,type:"家具"},{number:23516,type:"家具",sub_type:"沙发"},{number:29159,type:"办公用品"},{number:12321,type:"办公用品",sub_type:"笔"},{number:16838,type:"办公用品",sub_type:"纸张"},{number:18375,province:"浙江省",type:"家具",sub_type:"桌子"},{number:14043,province:"浙江省",type:"家具",sub_type:"沙发"},{number:4826,province:"浙江省",type:"办公用品",sub_type:"笔"},{number:5854,province:"浙江省",type:"办公用品",sub_type:"纸张"},{number:7818,province:"四川省",type:"家具",sub_type:"桌子"},{number:9473,province:"四川省",type:"家具",sub_type:"沙发"},{number:7495,province:"四川省",type:"办公用品",sub_type:"笔"},{number:10984,province:"四川省",type:"办公用品",sub_type:"纸张"},{number:13132,province:"浙江省",city:"杭州市",type:"家具"},{number:2288,province:"浙江省",city:"杭州市",type:"办公用品"},{number:15420,province:"浙江省",city:"杭州市"},{number:2999,province:"浙江省",city:"绍兴市",type:"家具"},{number:2658,province:"浙江省",city:"绍兴市",type:"办公用品"},{number:5657,province:"浙江省",city:"绍兴市"},{number:11111,province:"浙江省",city:"宁波市",type:"家具"},{number:2668,province:"浙江省",city:"宁波市",type:"办公用品"},{number:13779,province:"浙江省",city:"宁波市"},{number:5176,province:"浙江省",city:"舟山市",type:"家具"},{number:3066,province:"浙江省",city:"舟山市",type:"办公用品"},{number:8242,province:"浙江省",city:"舟山市"},{number:4174,province:"四川省",city:"成都市",type:"家具"},{number:6339,province:"四川省",city:"成都市",type:"办公用品"},{number:10513,province:"四川省",city:"成都市"},{number:4066,province:"四川省",city:"绵阳市",type:"家具"},{number:3322,province:"四川省",city:"绵阳市",type:"办公用品"},{number:7388,province:"四川省",city:"绵阳市"},{number:4276,province:"四川省",city:"南充市",type:"家具"},{number:6008,province:"四川省",city:"南充市",type:"办公用品"},{number:10284,province:"四川省",city:"南充市"},{number:4775,province:"四川省",city:"乐山市",type:"家具"},{number:2810,province:"四川省",city:"乐山市",type:"办公用品"},{number:7585,province:"四川省",city:"乐山市"},{number:32418,province:"浙江省",type:"家具"},{number:10680,province:"浙江省",type:"办公用品"},{number:43098,province:"浙江省"},{number:17291,province:"四川省",type:"家具"},{number:18479,province:"四川省",type:"办公用品"},{number:35770,province:"四川省"},{number:78868}]},config:{datas:[{label:"dimension",key:"dimension",required:true,type:"group"},{label:"metrics",key:"metrics",required:true,type:"aggregate"},{label:"filter",key:"filter",type:"filter",allowSameField:true}],styles:[{label:"graph.title",key:"graph",comType:"group",rows:[{label:"graph.smooth",key:"smooth",default:false,comType:"checkbox"},{label:"graph.step",key:"step",default:false,comType:"checkbox"}]},{label:"label.title",key:"label",comType:"group",rows:[{label:"label.showLabel",key:"showLabel",default:false,comType:"checkbox"},{label:"label.position",key:"position",comType:"select",default:"top",options:{items:[{label:"上",value:"top"},{label:"左",value:"left"},{label:"右",value:"right"},{label:"下",value:"bottom"},{label:"内",value:"inside"},{label:"内左",value:"insideLeft"},{label:"内右",value:"insideRight"},{label:"内上",value:"insideTop"},{label:"内下",value:"insideBottom"},{label:"内左上",value:"insideTopLeft"},{label:"内左下",value:"insideBottomLeft"},{label:"内右上",value:"insideTopRight"},{label:"内右下",value:"insideBottomRight"}]}},{label:"font",key:"font",comType:"font",default:{fontFamily:"PingFang SC",fontSize:"12",fontWeight:"normal",fontStyle:"normal",color:"black"}}]},{label:"legend.title",key:"legend",comType:"group",rows:[{label:"legend.showLegend",key:"showLegend",default:true,comType:"checkbox"},{label:"legend.type",key:"type",comType:"select",options:{items:[{label:"普通",value:"plain"},{label:"滚动",value:"scroll"}]}},{label:"legend.selectAll",key:"selectAll",default:true,comType:"checkbox"},{label:"legend.position",key:"position",comType:"select",default:"right",options:{items:[{label:"右",value:"right"},{label:"上",value:"top"},{label:"下",value:"bottom"},{label:"左",value:"left"}]}},{label:"font",key:"font",comType:"font",default:{fontFamily:"PingFang SC",fontSize:"12",fontWeight:"normal",fontStyle:"normal",color:"black"}}]},{label:"xAxis.title",key:"xAxis",comType:"group",rows:[{label:"common.showAxis",key:"showAxis",default:true,comType:"checkbox"},{label:"common.inverseAxis",key:"inverseAxis",comType:"checkbox"},{label:"common.lineStyle",key:"lineStyle",comType:"line",default:{type:"dashed",width:1,color:"black"}},{label:"common.showLabel",key:"showLabel",default:true,comType:"checkbox",options:[]},{label:"font",key:"font",comType:"font",default:{fontFamily:"PingFang SC",fontSize:"12",fontWeight:"normal",fontStyle:"normal",color:"black"}},{label:"common.rotate",key:"rotate",default:0,comType:"inputNumber"},{label:"common.showInterval",key:"showInterval",default:false,comType:"checkbox"},{label:"common.interval",key:"interval",default:0,comType:"inputNumber"}]},{label:"yAxis.title",key:"yAxis",comType:"group",rows:[{label:"common.showAxis",key:"showAxis",default:true,comType:"checkbox"},{label:"common.inverseAxis",key:"inverseAxis",default:false,comType:"checkbox"},{label:"common.lineStyle",key:"lineStyle",comType:"line",default:{type:"dashed",width:1,color:"black"}},{label:"common.showLabel",key:"showLabel",default:true,comType:"checkbox",options:[]},{label:"font",key:"font",comType:"font",default:{fontFamily:"PingFang SC",fontSize:"12",fontWeight:"normal",fontStyle:"normal",color:"black"}},{label:"common.showTitleAndUnit",key:"showTitleAndUnit",default:true,comType:"checkbox",options:[]},{label:"common.unitFont",key:"unitFont",comType:"font",default:{fontFamily:"PingFang SC",fontSize:"12",fontWeight:"normal",fontStyle:"normal",color:"black"}},{label:"common.nameLocation",key:"nameLocation",default:"center",comType:"select",options:{items:[{label:"开始",value:"start"},{label:"结束",value:"end"},{label:"中间",value:"center"}]}},{label:"common.nameRotate",key:"nameRotate",default:90,comType:"inputNumber"},{label:"common.nameGap",key:"nameGap",default:60,comType:"inputNumber"},{label:"common.min",key:"min",comType:"inputNumber"},{label:"common.max",key:"max",comType:"inputNumber"}]},{label:"splitLine.title",key:"splitLine",comType:"group",rows:[{label:"splitLine.showHorizonLine",key:"showHorizonLine",default:true,comType:"checkbox"},{label:"common.lineStyle",key:"horizonLineStyle",comType:"line",default:{type:"dashed",width:1,color:"grey"}},{label:"splitLine.showVerticalLine",key:"showVerticalLine",default:false,comType:"checkbox"},{label:"common.lineStyle",key:"verticalLineStyle",comType:"line",default:{type:"dashed",width:1,color:"grey"}}]},{label:"margin.title",key:"margin",comType:"group",rows:[{label:"margin.containLabel",key:"containLabel",default:true,comType:"checkbox"},{label:"margin.left",key:"marginLeft",default:"5%",comType:"marginWidth"},{label:"margin.right",key:"marginRight",default:"5%",comType:"marginWidth"},{label:"margin.top",key:"marginTop",default:"15%",comType:"marginWidth"},{label:"margin.bottom",key:"marginBottom",default:"5%",comType:"marginWidth"}]}],settings:[],i18ns:[{lang:"zh-CN",translation:{common:{showAxis:"显示坐标轴",inverseAxis:"反转坐标轴",lineStyle:"线条样式",borderType:"边框线条类型",borderWidth:"边框线条宽度",borderColor:"边框线条颜色",backgroundColor:"背景颜色",showLabel:"显示标签",unitFont:"刻度字体",rotate:"旋转角度",position:"位置",showInterval:"显示刻度",interval:"刻度间隔",showTitleAndUnit:"显示标题和刻度",nameLocation:"标题位置",nameRotate:"标题旋转",nameGap:"标题与轴线距离",min:"最小值",max:"最大值"},label:{title:"标签",showLabel:"显示标签",position:"位置"},legend:{title:"图例",showLegend:"显示图例",type:"图例类型",selectAll:"图例全选",position:"图例位置"},data:{color:"颜色",colorize:"配色"},graph:{title:"折线图",smooth:"平滑",step:"阶梯"},xAxis:{title:"X轴"},yAxis:{title:"Y轴"},splitLine:{title:"分割线",showHorizonLine:"显示横向分割线",showVerticalLine:"显示纵向分割线"},reference:{title:"参考线",open:"点击参考线配置"},cache:{title:"数据处理"}}}]},isISOContainer:"experiment-pivot-table-chart",dependency:["https://cdn.jsdelivr.net/npm/@antv/[email protected]/dist/index.min.js","https://cdn.jsdelivr.net/npm/@antv/[email protected]/dist/style.min.css"],meta:{id:"experiment-pivot-table-chart",name:"[Experiment]基于AntVS2的透视表",icon:"24gf-table",requirements:[{group:[0,999],aggregate:[0,999]}]},onMount(e,t){if("PivotSheet"in t.window.S2)this.chart=new t.window.S2.PivotSheet(t.document.getElementById(e.containerId),this.mockData,{})},onUpdated(e){if(!e.dataset||!e.dataset.columns||!e.config)return;this.chart&&this.chart.render()},onUnMount(){this.chart&&this.chart.dispose()},onResize(e,t){if(!this.chart)return;this.chart.changeSize(t.width,t.height);this.chart.render(false)},getOptions(t,n){const i=n.styles;const o=n.datas||[];const l=o.filter((e=>"group"===e.type)).flatMap((e=>e.rows||[]));const a=o.filter((e=>"aggregate"===e.type)).flatMap((e=>e.rows||[]));const r=e.transformToDataSet(t.rows,t.columns,o);const p=l.map((t=>({type:"category",boundaryGap:false,tooltip:{show:true},data:dataColumns.map((n=>n[e.getValueByColumnKey(t)]))})));const y=a.map(((t,n)=>({name:e.getColumnRenderName(t),type:n>0?"bar":"line",sampling:"average",areaStyle:this.isArea?{}:void 0,stack:this.isStack?"total":void 0,data:r.map((e=>e.getCell(t))),...this.getLabelStyle(i),...this.getSeriesStyle(i)})));const{min:c,max:s}=e.getDataColumnMaxAndMin2(r,a[0]);return{visualMap:{show:false,seriesIndex:0,type:"continuous",min:c,max:s},tooltip:{trigger:"axis"},legend:this.getLegendStyle(i,y.map((e=>e?.name))||[]),grid:this.getGrid(i),xAxis:this.getXAxis(i,p),yAxis:this.getYAxis(i,y),series:y}},getGrid(t){const[n,i,o,l,a]=e.getStyles(t,["margin"],["containLabel","marginLeft","marginRight","marginBottom","marginTop"]);return{left:i,right:o,bottom:l,top:a,containLabel:n}},getYAxis(t,n){const[i,o,l,a,r,p,y,c,s,m,b,u]=e.getStyles(t,["yAxis"],["showAxis","inverseAxis","lineStyle","showLabel","font","showTitleAndUnit","unitFont","nameLocation","nameGap","nameRotate","min","max"]);const[h,d]=e.getStyles(t,["splitLine"],["showHorizonLine","horizonLineStyle"]);const g=p?n.map((e=>e.name)).join(" / "):null;return{type:"value",name:g,nameLocation:c,nameGap:s,nameRotate:m,inverse:o,min:b,max:u,axisLabel:e.getAxisLabel(a,r),axisLine:e.getAxisLine(i,l),axisTick:e.getAxisTick(a,l),nameTextStyle:e.getNameTextStyle(y?.fontFamily,y?.fontSize,y?.color),splitLine:e.getSplitLine(h,d)}},getXAxis(t,n){const i=n[0];const[o,l,a,r,p,y,c,s]=e.getStyles(t,["xAxis"],["showAxis","inverseAxis","lineStyle","showLabel","font","rotate","showInterval","interval"]);const[m,b]=e.getStyles(t,["splitLine"],["showVerticalLine","verticalLineStyle"]);return{...i,inverse:l,axisLabel:e.getAxisLabel(r,p,c?s:null,y),axisLine:e.getAxisLine(o,a),axisTick:e.getAxisTick(r,a),splitLine:e.getSplitLine(m,b)}},getLegendStyle(t,n){const[i,o,l,a,r]=e.getStyles(t,["legend"],["showLegend","type","font","position","selectAll"]);let p={};let y={};switch(a){case"top":y="horizontal";p={top:8,left:8,right:8,height:32};break;case"bottom":y="horizontal";p={bottom:8,left:8,right:8,height:32};break;case"left":y="vertical";p={left:8,top:16,bottom:24,width:96};break;default:y="vertical";p={right:8,top:16,bottom:24,width:96};break}const c=n.reduce(((e,t)=>({...e,[t]:r})),{});return{...p,show:i,type:o,orient:y,selected:c,data:n,textStyle:l}},getLabelStyle(t){const[n,i,o]=e.getStyles(t,["label"],["showLabel","position","font"]);return{label:{show:n,position:i,...o}}},getSeriesStyle(t){const[n,i]=e.getStyles(t,["graph"],["smooth","step"]);return{smooth:n,step:i}},getStyleValueByGroup(e,t,n){const i=n.split(".");return this.getStyleValue(e,[t,...i])}}}return e})();