icCube - 在amCharts组合图表的列中为2维设置serie颜色

时间:2015-09-21 08:16:29

标签: amcharts iccube iccube-reporting

我有以下动态图表(见附图)。为了重现性,我基于标准的icCube销售模型创建了一个非常简单的图表。

这个想法是在列轴上有两个事实,其中包含所选年份的数据。为了区分我想要为多年来逐渐消失的事实分配颜色的事实。当您添加年份时,新年将获得属于事实的颜色,但稍微轻一点。下面的屏幕将澄清。

我的问题是:有没有办法使用与icCube的MDX /设置相关的amCharts / combo?

在附件中,您会看到两个图表: this is what I intend

但是当我取消选择2008时,会发生这种情况: this happens/ the issue

我已经包含了JSON,因此您可以在简单的vanilla icCUbe 5.1.2安装的Sales演示中重现这一点。

    {
    "classID": "ic3.ReportGuts",
    "guts_": {
        "ic3Version": 12,
        "schemaName": "Sales",
        "cubeName": "Sales",
        "layout": {
            "classID": "ic3.FixedLayout",
            "guts_": {
                "ic3Version": 12,
                "grid": 10,
                "boxes": [
                    {
                        "classID": "ic3.FixedLayoutBox",
                        "guts_": {
                            "ic3Version": 12,
                            "header": "chart with color serie that should match the selected fact (orange = Amount, blue = Amount_2)",
                            "behaviour": "Fixed Box",
                            "noPrint": false,
                            "position": {
                                "top": 100,
                                "left": 0,
                                "width": 1021,
                                "height": 421
                            },
                            "widgetAdapterUid": "w12",
                            "zIndex": 2008
                        }
                    },
                    {
                        "classID": "ic3.FixedLayoutBox",
                        "guts_": {
                            "ic3Version": 12,
                            "header": "select years",
                            "behaviour": "Fixed Box",
                            "noPrint": false,
                            "position": {
                                "top": 0,
                                "left": 60,
                                "width": 630,
                                "height": 80
                            },
                            "widgetAdapterUid": "w14",
                            "zIndex": 2009
                        }
                    }
                ],
                "theme": "Classic",
                "sizeIndicator": {
                    "width": 1024,
                    "height": 708
                }
            }
        },
        "widgetMgr": {
            "classID": "ic3.WidgetAdapterContainerMgr",
            "guts_": {
                "ic3Version": 12,
                "items": [
                    {
                        "classID": "ic3.AmchartsComboAdapter",
                        "guts_": {
                            "ic3Version": 12,
                            "navigationGuts": {
                                "classID": "ic3.AmChartsNavigationStrategy",
                                "guts_": {
                                    "ic3Version": 12,
                                    "menuVisibility": {
                                        "back": true,
                                        "axisXChange": "All",
                                        "axisYChange": "All",
                                        "filter": "All",
                                        "reset": true,
                                        "widget": true,
                                        "others": "All"
                                    },
                                    "maxAxisMemberCount": 10,
                                    "selectionMode": "disabled",
                                    "drillDownStrategy": {
                                        "type": "mdxExpression",
                                        "options": {
                                            "drd_mdx": "order(nonempty($member.children, @{selMeasure}), @{selMeasure}, BDESC)"
                                        }
                                    }
                                }
                            },
                            "ic3_name": "widget-1",
                            "ic3_uid": "w12",
                            "ic3_eventMapper": {
                                "classID": "ic3.EventWidgetMapper",
                                "guts_": {
                                    "__ic3_widgetEventsDescription": {},
                                    "fireOnRefresh": {
                                        "name": "All Events (default)",
                                        "uniqueName": "all",
                                        "parentRowId": -1,
                                        "type": "OT"
                                    },
                                    "ic3queryRefresh": "selDimensie"
                                }
                            },
                            "ic3_mdxBuilderUid": "m6",
                            "__ic3_widgetTypeName": "amCharts/Combo",
                            "ic3extraOptions": ":{  \"categoryAxis\": {\n    \"gridPosition\": \"middle\",\n    \"gridAlpha\": 0,\n    \"labelFunction\": function(valueText, serialDataItem, categoryAxis) {\n        return valueText.substr(0,10).replace(/\\s+/g, '<br>');\n    }\n  }\n\n }",
                            "graphs": [
                                {
                                    "lineThickness": 3,
                                    "balloonText": "[[category]]<br>[[title]]: <b>[[fValue]]</b>"
                                }
                            ],
                            "ic3ChartType": [
                                "column",
                                "column"
                            ],
                            "legendPosition": "bottom"
                        }
                    },
                    {
                        "classID": "ic3.QueryFilterButtonListAdapter",
                        "guts_": {
                            "ic3Version": 12,
                            "ic3_name": "widget-0",
                            "ic3_uid": "w14",
                            "ic3_eventMapper": {
                                "classID": "ic3.EventWidgetMapper",
                                "guts_": {
                                    "ic3selection": "selYear",
                                    "__ic3_widgetEventsDescription": {}
                                }
                            },
                            "ic3_mdxBuilderUid": "m1",
                            "__ic3_widgetTypeName": "icCube/Buttons",
                            "selectionMode": "multi",
                            "layout": "horizontal"
                        }
                    }
                ]
            }
        },
        "constantMgr": {
            "classID": "ic3.ConstantsMgr",
            "guts_": {
                "constant": []
            }
        },
        "cssMgr": {
            "classID": "ic3.CssMgr",
            "guts_": {}
        },
        "javascriptMgr": {
            "classID": "ic3.ReportJavascriptMgr",
            "guts_": {
                "ic3Version": 12,
                "js": "/**                                                                      \n * A function called each time an event is generated.                    \n *                                                                       \n * @param context the same object is passed between consumeEvent calls.  \n *                Can be used to store information.                      \n *        {                                                              \n *          $report   : jQuery context of the report container           \n *          fireEvent : a function( name, value ) triggering an event    \n *        }                                                              \n *                                                                       \n * @param event the event information                                    \n *                                                                       \n          {                                                              \n *          name  : as specified in the 'Events' tab                     \n *          value : (optional) actual event value                        \n *          type  : (optional) e.g., ic3selection                        \n *        }                                                              \n *                                                                       \n * Check the 'Report Event Names' menu for the list of available events. \n */                                                                      \n/*                                                                       \nfunction consumeEvent( context, event ) {                                \n  if (event.name == 'ic3-report-init') {                                 \n    // add your code here                                                \n  }                                                                      \n}                                                                        \n*/                                                                       \n"
            }
        },
        "calcMeasureMgr": {
            "classID": "ic3.CalcMeasureMgr",
            "guts_": {
                "measures": [
                    {
                        "name": "Amount2",
                        "expression": "1.1*[amount]",
                        "properties": null
                    }
                ]
            }
        },
        "mdxQueriesMgr": {
            "classID": "ic3.MdxQueriesContainerMgr",
            "guts_": {
                "mdxQueries": {
                    "classID": "ic3.BaseContainerMgr",
                    "guts_": {
                        "ic3Version": 12,
                        "items": [
                            {
                                "classID": "ic3.QueryBuilderWidget",
                                "guts_": {
                                    "mdxWizard": {
                                        "classID": "ic3.QueryBuilderWizardForm",
                                        "guts_": {
                                            "rows": [
                                                {
                                                    "classID": "ic3.QueryBuilderHierarchyForm",
                                                    "guts_": {
                                                        "hierarchy": {
                                                            "name": "Product",
                                                            "uniqueName": "[Product].[Product]"
                                                        },
                                                        "type": "membersOfLevel",
                                                        "membersOfLevel": "[Product].[Product].[Article]"
                                                    }
                                                }
                                            ],
                                            "cols": [
                                                {
                                                    "classID": "ic3.QueryBuilderMeasuresFormBase",
                                                    "guts_": {
                                                        "measures": [
                                                            {
                                                                "name": "Amount",
                                                                "uniqueName": "[Measures].[Amount]",
                                                                "type": "ME"
                                                            },
                                                            {
                                                                "name": "Amount2",
                                                                "uniqueName": "[Measures].[Amount2]",
                                                                "type": "RCME"
                                                            }
                                                        ]
                                                    }
                                                },
                                                {
                                                    "classID": "ic3.QueryBuilderEventsFilter",
                                                    "guts_": {
                                                        "mdxStatement": "@{selYear}"
                                                    }
                                                }
                                            ],
                                            "filters": [],
                                            "nonEmptyOnRows": false,
                                            "nonEmptyOnColumns": false
                                        }
                                    },
                                    "mdxFlat": {
                                        "classID": "ic3.QueryBuilderFlatMdxForm",
                                        "guts_": {
                                            "useMdxStatement": false
                                        }
                                    },
                                    "ic3_name": "mdx Query-0",
                                    "ic3_uid": "m6"
                                }
                            }
                        ]
                    }
                },
                "mdxFilter": {
                    "classID": "ic3.BaseContainerMgr",
                    "guts_": {
                        "ic3Version": 12,
                        "items": [
                            {
                                "classID": "ic3.NewFilterQueryBuilderForm",
                                "guts_": {
                                    "hierarchy": {
                                        "name": "Year",
                                        "uniqueName": "[Time].[Year]"
                                    },
                                    "type": "membersOfLevel",
                                    "membersOfLevel": "[Time].[Year].[Year]",
                                    "defaultsMdx": "2008,2009,2010",
                                    "addDefaultMember": false,
                                    "useAllMember": false,
                                    "useDefaultMemberIfEmpty": false,
                                    "ic3_name": "mdx Filter-0",
                                    "ic3_uid": "m1"
                                }
                            }
                        ]
                    }
                },
                "actionBuilders": {
                    "classID": "ic3.BaseContainerMgr",
                    "guts_": {
                        "ic3Version": 12,
                        "items": []
                    }
                }
            }
        }
    }
}

3 个答案:

答案 0 :(得分:2)

目前的报告版本(5.1.2)无法实现。我们在这里看到的是根据选择使用不同的调色板。

您必须为每列创建一个新的graph,以指定valueField及其颜色。但是列数正在发生变化,因此我们不知道应该定义多少graph

答案 1 :(得分:1)

已经读过没有答案了。我创建了以下解决方法:

  • 我将显示的总年数总计为4年
  • 在MDX声明中我

这是我使用的MDX语句:

 WITH
 MEMBER [Time].[Year].[All-M].[_1] as null
 MEMBER [Time].[Year].[All-M].[_2] as null
 MEMBER [Time].[Year].[All-M].[_3] as null
 MEMBER [Measures].[Amount2] AS 1.1*[amount]
 SET [selection] as  order( @{selYear},[Time].[Year].currentmember.key, bdesc) +
     [Time].[Year].[All-M].[_1] + [Time].[Year].[All-M].[_2] + [Time].[Year].[All-M].[_3] 
 SELECT {[measures].[Amount]} *  [Time].[Year].[All-M].[_1]
+ item( ({[measures].[Amount]} *  {[selection]}),3) 
+ item( ({[measures].[Amount]} *  {[selection]}),2) 
+ item( ({[measures].[Amount]} *  {[selection]}),1) 
+ item( ({[measures].[Amount]} *  {[selection]}),0)
+ item( ({[measures].[Amount2]} *  {[selection]}),3) 
+ item( ({[measures].[Amount2]} *  {[selection]}),2) 
+ item( ({[measures].[Amount2]} *  {[selection]}),1) 
+ item( ({[measures].[Amount2]} *  {[selection]}),0)
 ON COLUMNS,
{ [Product].[Product].[Article].allmembers } ON ROWS
 FROM [Sales]

我不知道为什么我必须选择第一个元组(金额* _1),但如果我不选择它,我会收到MDX错误。

尽管如此,我现在获得了一个完美调整的图表: 4 years selected 2 years selected

希望它对其他人有所帮助。

答案 2 :(得分:0)

在当前版本中,您可以使用主题调色板或成员(@ Ic3Color)中MDX级别定义的颜色的列颜色。要激活第二个选项,请设置标记&#39;使用MDX成员颜色&#39;在报告中。

在您的示例中,它更像是一个单元格属性,用于在表格中设置动态颜色(请参阅example)。抱歉,目前没有简单的方法将单元格的属性与图表的列填充颜色绑定。