IcCube - 具有重复名称的树形图图表

时间:2016-08-11 10:30:38

标签: google-visualization treemap iccube-reporting

在Google Treemap Chart中,每个节点都必须具有唯一ID,但两个节点可以具有相同的名称(https://groups.google.com/d/msg/google-visualization-api/UDLD-a-0PCM/IwVCGzsWOg8J)。

我使用了父/子演示(http://www.iccube.com/support/documentation/user_guide/schemas_cubes/dim_parentchild.php

中的模式

只要节点的名称是唯一的,就可以在树形图中使用以下MDX语句:

WITH
  MEMBER [parent_name] as IIF( [dim (ALL)].[Hierarchy].currentmember 
  is  [dim (ALL)].[Hierarchy].[ALL],'',
  [dim (ALL)]. [Hierarchy].currentmember.parent.name )
SELECT
  {[parent_name],[Measures].[value]} on 0,
  non empty [dim (ALL)].[Hierarchy].members on 1
FROM
  [Cube]  

如果我将该行添加到icCube架构中的内存表中:

7,4,Spain, 2, 32 

但在渲染Treemap时,名称Spain是双倍的。为了支持名称,GVI表中的子定义应该是这样的:

{v:'uniqueID-Spain', f:'Spain'}

2 个答案:

答案 0 :(得分:2)

作为一种解决方法,您可以使用以下代码修改Google树窗口小部件的GviTable处理。查看此处的示例: https://drive.google.com/file/d/0B3kSph_LgXizSVhvSm15Q1hIdW8/view?usp=sharing

报告JavaScript:

function consumeEvent( context, event ) {
    if (event.name == 'ic3-report-init') {
        if(!_.isFunction(ic3.originalProcessGviTable)) {
            ic3.originalProcessGviTable = viz.charts.GenericGoogleWidget.prototype.processGviTable
        }

        viz.charts.GenericGoogleWidget.prototype.processGviTable = function(gviTable){
            if(this.props.ic3chartType === "TreeMap") {
                gviTable = gviTable || this.gviTable();
                var underlying = _.cloneDeep(gviTable.getUnderlyingGviTable());
                _.each(underlying.rows, function(row){
                    // Replace id with parent prefixed
                    if(_.isObject(row.c[0]) && !_.isString(row.c[0].f)) {
                        row.c[0].f = row.c[0].v;
                        if(_.isObject(row.c[0].p) && _.isString(row.c[0].p.mun)) {
                            row.c[0].v = row.c[0].p.mun;
                        }
                    }
                });
                gviTable = viz.GviTable.fromSnapshot(underlying);
                this.startColumnSelection = gviTable.getNumberOfHeaderColumns() - 1;
                return viz.charts.toGoogleDataTableOneRowHeader(gviTable);
            } else {
                return ic3.originalProcessGviTable.apply(this, gviTable);
            }
        }
    }
}

对于类似的查询:

WITH
  MEMBER [parent_name] as 
    IIF( [dim (ALL)].[Hierarchy].currentmember.isAll(),
        '', 
        ([dim (ALL)].[Hierarchy].currentmember.parent.uniqueName) 
    )
SELECT
  {[parent_name],[Measures].[value]} on 0,
  non empty [dim (ALL)].[Hierarchy].members on 1
FROM 
  [Cube]

答案 1 :(得分:0)

这是Google Treemap图表的限制,该图表使用相同的列作为id和标签。除了更改名称以确保它们是唯一的(例如添加父项),我没有看到解决方法。

一个选项是使用另一个没有此限制的Treemap图表(例如D3中的一个)。

--- icCube Schema ---

架构正在运行(只使用,而不是;作为分隔符) enter image description here

--- icCube报道---

使用Treemap的问题是你有两行具有相同的ID(德国),fiddle

This fiddle is a running example of treemap