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

IcCube - Treemap Chart with duplicate names

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

我使用了 parent/child 演示中的模式 (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 的架构中将行添加到内存中 table:

7,4,Spain, 2, 32 

但是在渲染树形图时名称西班牙是双重的。为了支持名称,GVI table 中的子定义应该是这样的:

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

这是 Google 树形图的限制,它使用同一列作为 ID 和标签。除了更改名称以确保它们是唯一的(例如添加父项)之外,我没有看到解决此问题的方法。

一个选项是使用另一个没有此限制的树状图图表(例如来自 D3 的图表)。

--- icCube 架构 ---

架构有效(只需使用 , 而不是 ; 作为分隔符)

---爱立方报告---

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

This fiddle is a running example of treemap

作为解决方法,您可以使用以下代码修改 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]