The open source PR of complex table header tables has been introduced before, which is earlier and based on Metabase V0.30 version, while Metabase V0.33 version has changed greatly, so if the PR of Metabase complex table header table functions need to be reformed in the new version. Of course, if the ability allows, you can also follow their own ideas to achieve.

For details, please visit Github PR: Metabase Pull Request #8427

The effect is as follows:

implementation

Make a clone of the summaryTable branch by going to the Metabase fork under R-hot.

Because Metabase has a complete architecture and is highly componentalized, there is no need to worry about the impact on the code and the coupling is relatively low.

The author has added a new type of visualization:

So, you can follow this new visual component, find the files you need, PivotTable components used by most of the components start with summary or contain summary, here is not a list, and then put the latest version of Metabase source code corresponding directory below, and then compile and start it.

Note: Metabase PivotTable uses some open source NPM components that need to be introduced, as well as the implementation analysis in my last article

However, since the data structure returned by the old and new versions of Metabase is changed, it needs to be processed before normal functions can be realized. Therefore, the following two solutions are given:

Plan a

It is not clear why Metabase removed columns, nor is it likely that they were removed because they were not needed. At least in my opinion, it was very convenient to keep columns, and PivotTable PR took full advantage of this. Although the new version is said to be removed, but not completely removed, just screened. So the first scheme is to put out the columns, PivotTable function can be used normally.

Find code directory/SRC/metabase query_processor/middleware/dev CLJ the code

;; Add AA (complement :columnsAA) to complement"QP results should no longer include :columns."))
Copy the code

Scheme 2

If you don’t want colums to be released in future code updates, you need to handle columns in the PivotTable code. One way to handle columns is to get columns from cols. You can also handle columns in other ways or even replace colums. The recommended solution is as follows:

  columns = []
  if(cols.length>0){
​    cols.map(item=>{
​      columns.push(item.name)
​    })
  }
Copy the code

Remark: There are a lot of columns in it and there are a lot of things that need to be dealt with. At present, I am not sure whether it will cause other problems. However, from the point of view of the present, the efficiency of this kind of PivotTable achieved by JS will be low.

A blog address: dumplingbao. Making. IO / 2020/02/27 /…