多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
css样式 在designer.css desing.css ~~~ /* 表格图例 */ .zuan_tag>li{ display: inline-block; cursor: pointer; } ~~~ main.html 里 加开启组件html片段 ~~~ <div ng-switch-when="drillDownSelect"> <div class="col col-xs-5" style="line-height:30px;"> {{element.title}} </div> <div class="col col-xs-7" style2="max-height:300px; overflow-y:auto;padding-right:10px !important;"> <ui-select multiple sortable="true" close-on-select="false" ng-model="component.config[element.bind].drillDown" theme="select2" ng-disabled="disabled" style="width:100%;"> <ui-select-match placeholder="">{{$item.label}}</ui-select-match> <ui-select-choices repeat="item in component.config.datasourceConfig.metadataConfig.metadataTable.modelInfo.dimensions | filter:$select.search"> <span ng-bind-html="item.label | highlight: $select.search"></span> </ui-select-choices> </ui-select> </div> </div> ~~~ vs-component-widget-grid。js // 3357行 d.internalBuildColumnDescription(t, m, o, n, q); 下面 ~~~ var x = { name: "zuanqu", title: "数据钻取", groups: [] }; x.groups.push({ name: "", title: { text: "数据钻取" }, elements: [ { title: "下钻开启", bind: "drilling_show", type: "switch-55", on: vsLang.on, off: vsLang.off }] }); if (t.component.config.datasourceConfig == null) { t.component.config.datasourceConfig = {} } var U = function() { return t.component.config.datasourceConfig != null && t.component.config.datasourceConfig.metadataConfig != null && t.component.config.datasourceConfig.metadataConfig.metadataTable != null && t.component.config.datasourceConfig.datasourceType == "metadata" }; x.groups.push({ show: U, title: { text: "维度选择" }, elements: [{ title: "选择"+vsLang.dimension, type: "drillDownSelect", bind: "datasourceConfig" }] }); var ac = null; if (t.component.config.datasourceConfig.metadataConfig != null) { ac = t.component.config.datasourceConfig.metadataConfig.metadataTable.modelInfo } x.groups.push({ name: "", title: { text: "图例" }, elements: [{ title: "开启-关闭", type: "switch", bind: "drilling_tu", on: vsLang.on, off: vsLang.off, }, { title: "水平位置", type: "radio-icon", bind: "legendPosX", items: [{ name: "左对齐", value: "left", icon: "fa fa-align-left" },{ name: "居中", value: "center", icon: "fa fa-align-center" },{ name: "右对齐", value: "right", icon: "fa fa-align-right" }] },{ title: vsLang.font_color, type: "colorpicker", bind: "drilling_color" }] }); console.log(x) // 监听数据钻取开启与关闭 t.$watch("component.config.drilling_show", function (v, u) { var p = o.config.chartConfig; if (v != null && (u == null || u !== v)) { // console.log(v) o.config.drilling_show = v; console.log(o.config.drilling_show) } }); // 转取方式 t.$watch("component.config.drillingType", function (v, u) { var p = o.config.chartConfig; if (v != null && (u == null || u !== v)) { console.log(v) console.log(u) } }); // 显示或隐藏 t.$watch("component.config.drilling_tu", function (v, u) { if (v != null && (u == null || u !== v)) { var p = o.config.chartConfig; console.log(v) if(v == true){ p.drillingShow = 'block' console.log(p) o.context.chart.setOption(p) }else if(v == false){ p.drillingShow = 'none' console.log(p) o.context.chart.setOption(p) } } }); // 新增加 // end // 字体颜色 t.$watch("component.config.drilling_color", function (w, u) { if (w != null && g.isValidColor(w)) { var v = o.config.chartConfig; v.drilling_color = w; o.context.chart.setOption(v) } }); // 垂直方向 // t.$watch('component.config.legendPosY', function(w, u){ // if(w != null && (u == null || w !== u)){ // var v = o.config.chartConfig; // v.legendPosY = w; // console.log(v.legendPosY) // o.context.chart.setOption(v) // } // }); //水平方向 t.$watch('component.config.legendPosX', function(w, u){ if(w != null && (u == null || w !== u)){ var v = o.config.chartConfig; v.drilling_x = w; console.log(v.drilling_x) o.context.chart.setOption(v) } }); o.description.categories.push(x); // end ~~~ ![](https://box.kancloud.cn/98d5911ff5739750eab3b7671d0369f9_1238x669.png) ![](https://box.kancloud.cn/60b9541af3b7353c2fcdcf9404e5503c_1163x760.png) # 分别添加 在design.js也就是分享页 也要添加这两行代码 `o.push("<div class='zuan_tag' style='width:100%;right:0;height:40px;line-height:40px;' ng-style=\"{'display':component.config.drilling_tu?'block':'none' ,'color':component.config.drilling_color ,'text-align':component.config.legendPosX }\" ><li ng-repeat='item in component.config.datasourceConfig.drillDown'>{{ item.label }}>></li></div>");` ![](https://box.kancloud.cn/1705d3fd52f0c1231a76bedcac7fe89f_831x841.png) # 添加这行代码 `s.config.drillDown = true;` # 在点击事件里添加 ![](https://box.kancloud.cn/4a5f606667f28e322f0ebbac43474c33_918x939.png) ![](https://box.kancloud.cn/d66fa6dd3af5c5defd78f9f4590fa28a_1065x719.png) 搜索component.config.chartConfig.onRowSelected = function(d, i, orgIndex) { 可以找到代码位置 具体添加代码如下: ~~~ // 判断下钻 if(i==orgIndex && component.config.drilling_show === true){ isACtive = true; // console.log(index) var d = component.config.datasourceConfig.dimensions; if(index <=number.length ){ alert("111") index++; number[index] = d[0]; // component.config.datasourceConfig.drillDown = component.config.datasourceConfig.dimensions; // component.config.datasourceConfig.drillDown[index] = component.config.datasourceConfig.dimensions[index]; newDimensions.push(component.config.datasourceConfig.drillDown[index]); console.log(component.config.datasourceConfig.drillDown[index+1]) } // number.push(d[0]) // console.log(number) console.log(component.config.datasourceConfig.drillDown) function test(){ var dimensions = component.config.datasourceConfig.drillDown; var measures = component.config.datasourceConfig.measures; if (dimensions && dimensions.length > 0) { scope.component.config.showDimensionBar = true; console.log(dimensions) scope.queryModelData({ eventParam: {}, dimensions: dimensions, measures: measures, tableKey: component.config.datasourceConfig.metadataConfig.metadataTable.key, number:{ data:number, paramKeys:component.config.datasourceConfig.drillDown, newDimensions:newDimensions }, onQuerySuccess: function(response) { if (response.data.success) { console.log(response.data) refreshChartView(); // console.log('kanaknkankan') console.log(component.config.chartConfig.data) } else { console.log(response.data.message) } }, onError: function() {} }) } } scope.$on(event_refreshBindingData,test() ) } ~~~ 搜索代码上面添加这个 ~~~ var dril = (component.config.datasourceConfig.drillDown.length); var number = new Array(dril) for(var i = 0;i < dril;i++){ number[i]=''; } var newDimensions = []; // console.log(number) var index = -1; ~~~ # engine.js 查看最终参数变化的位置 ![](https://box.kancloud.cn/bf630f1afe27acc6b3af8c1f81f02f51_650x929.png) 查看具体代码变化的主要字段 数组的顺序索引要保持一致 不然没有数据 ![](https://box.kancloud.cn/54edc7a6464db4c63333c5f04229385b_1269x554.png)