清除capabilities.json的示例使用Matrix数据视图映射

时间:2017-07-28 17:12:48

标签: powerbi

有人请指导我一个明确示例,它解释了如何正确构建一个能够专门用于矩阵数据视图映射的能力.json文件 ?我了解Microsoft's GitHub info regarding data binding,包括其有关数据角色和数据视图映射的详细信息的链接,但它并没有真正解决矩阵数据视图映射问题。我已经找到了很多关于分类和表数据映射的信息,但几乎没有关于矩阵的任何信息。感谢。

1 个答案:

答案 0 :(得分:0)

这是我最近使用的功能json文件的示例,该文件至少需要四个输入(使用两个分组和两个度量)。结果将导致使用“系列”数据角色作为三个列值的父级的分层视图。

JSON:

{
    "dataRoles": [
        {
            "name": "Series",
            "kind": "Grouping",
            "displayName": "Legend and Index",
            "displayNameKey": "Role_DisplayName_Legend"
        },
        {
            "name": "X",
            "kind": "Measure",
            "displayName": "X Axis",
            "displayNameKey": "Role_DisplayName_X"
        },
        {
            "name": "Y",
            "kind": "Measure",
            "displayName": "Y Axis",
            "displayNameKey": "Role_DisplayName_Y"
        },
        {
            "name": "Size",
            "kind": "Measure",
            "displayName": "Size",
            "displayNameKey": "Role_DisplayName_Size"
        },
        {
            "name": "Gradient",
            "kind": "Measure",
            "displayName": "Color saturation",
            "displayNameKey": "Role_DisplayName_Gradient"
        },
        {
            "name": "ColorFill",
            "kind": "Grouping",
            "displayName": "Customized Color",
            "displayNameKey": "Role_DisplayName_CustomizedColor"
        },
        {
            "name": "Shape",
            "kind": "Measure",
            "displayName": "Shape",
            "displayNameKey": "Role_DisplayName_Shape"
        },
        {
            "name": "Image",
            "kind": "Grouping",
            "displayName": "Image",
            "displayNameKey": "Role_DisplayName_Image"
        },  
        {
            "name": "Rotation",
            "kind": "Measure",
            "displayName": "Rotation",
            "displayNameKey": "Role_DisplayName_Rotation"
        },
        {
            "name": "Backdrop",
            "kind": "Grouping",
            "displayName": "Backdrop",
            "displayNameKey": "Role_DisplayName_Backdrop"
        },
        {
            "name": "X Start",
            "kind": "Measure",
            "displayName": "X Start",
            "displayNameKey": "Role_DisplayName_XStart"
        },
        {
            "name": "X End",
            "kind": "Measure",
            "displayName": "X End",
            "displayNameKey": "Role_DisplayName_XEnd"
        },
        {
            "name": "Y Start",
            "kind": "Measure",
            "displayName": "Y Start",
            "displayNameKey": "Role_DisplayName_YStart"
        },
        {
            "name": "Y End",
            "kind": "Measure",
            "displayName": "Y End",
            "displayNameKey": "Role_DisplayName_YEnd"
        }
    ],

    "dataViewMappings": [{
            "conditions": [
                {
                    "Series": { "max": 2 }, "X": { "max": 1 }, "Y": { "max": 1 }, "Size": { "max": 1 }, "Gradient": { "max": 1 }, "ColorFill": { "max": 0 },
                    "Shape": { "max": 1 }, "Image": { "max": 0 }, "Rotation": { "max": 1 }, "Backdrop": { "max": 1 }, "XStart": { "max": 1 }, 
                    "XEnd": { "max": 1 }, "YStart": { "max": 1 }, "YEnd": { "max": 1 } 
                },
                {   
                    "Series": { "max": 2 }, "X": { "max": 1 }, "Y": { "max": 1 }, "Size": { "max": 1 }, "Gradient": { "max": 0 }, "ColorFill": { "max": 1 }, 
                    "Shape": { "max": 1 }, "Image": { "max": 0 }, "Rotation": { "max": 1 }, "Backdrop": { "max": 1 }, "XStart": { "max": 1 }, 
                    "End": { "max": 1 }, "YStart": { "max": 1 }, "YEnd": { "max": 1 } 
                },
                {   
                    "Series": { "max": 2 }, "X": { "max": 1 }, "Y": { "max": 1 }, "Size": { "max": 1 }, "Gradient": { "max": 0 }, "ColorFill": { "max": 0 }, 
                    "Shape": { "max": 0 }, "Image": { "max": 1 }, "Rotation": { "max": 1 }, "Backdrop": { "max": 1 }, "XStart": { "max": 1 }, 
                    "XEnd": { "max": 1 }, "YStart": { "max": 1 }, "YEnd": { "max": 1 }
                },
                {
                    "Series": { "max": 2 }, "X": { "max": 1 }, "Y": { "max": 1 }, "Size": { "max": 1 }, "Gradient": { "max": 0 }, "ColorFill": { "max": 1 },
                    "Shape": { "max": 1 }, "Image": { "max": 0 }, "Rotation": { "max": 1 }, "Backdrop": { "max": 1 }, "XStart": { "max": 1 }, 
                    "XEnd": { "max": 1 }, "YStart": { "max": 1 }, "YEnd": { "max": 1 }
                },
                {
                    "Series": { "max": 2 }, "X": { "max": 1 }, "Y": { "max": 1 }, "Size": { "max": 1 }, "Gradient": { "max": 0 }, "ColorFill": { "max": 0 },
                    "Shape": { "max": 0 }, "Image": { "max": 1 }, "Rotation": { "max": 1 }, "Backdrop": {"max": 1 }, "XStart": { "max": 1 },
                    "XEnd": { "max": 1 }, "YStart": { "max": 1 }, "YEnd": { "max": 1 }
                }
            ],

            "matrix": {
                "rows": {
                    "for": {
                        "in": "Series"
                    },
                    "dataReductionAlgorithm": {
                        "sample": {
                            "count": 70000
                        }
                    }
                },
                "columns": {
                    "for": {
                        "in": "Category"
                    },
                    "dataReductionAlgorithm": {
                        "top": {
                            "count": 3
                        }
                    }
                },
                "values": {
                    "select": [
                        {
                            "bind": {
                                "to": "X"
                            }
                        },
                        {
                            "bind": {
                                "to": "Y"
                            }
                        }
                    ]
                },
                "sorting": {
                    "implicit": {
                        "clauses": [
                            {
                                "role": "Series",
                                "direction": 1
                            }
                        ]
                    }
                },

            "categorical": {
                "categories": {
                    "select": [
                        {
                            "bind": {
                                "to": "Series"
                            }
                        },
                        {
                            "bind": {
                                "to": "ColorFill"
                            }
                        },
                        {
                            "bind": {
                                "to": "Image"
                            }
                        },
                        {
                            "bind": {
                                "to": "Backdrop"
                            }
                        }
                    ]
                },
                    "values": {
                        "select": [
                            {
                                "bind": {
                                    "to": "X"
                                }
                            },
                            {
                                "bind": {
                                    "to": "Y"
                                }
                            },
                            {
                                "bind": {
                                    "to": "Size"
                                }
                            },
                            {
                                "bind": {
                                    "to": "Gradient"
                                }
                            },
                            {
                                "bind": {
                                    "to": "Shape"
                                }
                            },
                            {
                                "bind": {
                                    "to": "Rotation"
                                }
                            },
                            {
                                "bind": {
                                    "to": "X Start"
                                }
                            },
                            {
                                "bind": {
                                    "to": "X End"
                                }
                            },
                            {
                                "bind": {
                                    "to": "Y Start"
                                }
                            },
                            {
                                "bind": {
                                    "to": "Y End"
                                }
                            }
                        ]
                    }
                }
            }
        }],

    "objects": {
        "dataPoint": {
            "displayName": "Data colors",
            "displayNameKey": "Visual_DataPoint",
            "properties": {
                "defaultColor": {
                    "displayName": "Default color",
                    "displayNameKey": "Visual_DefaultColor",
                    "type": {
                        "fill": {
                            "solid": {
                                "color": true
                            }
                        }
                    }
                },
                "showAllDataPoints": {
                    "displayName": "Show all",
                    "displayNameKey": "Visual_DataPoint_Show_All",
                    "type": {
                        "bool": true
                    }
                },
                "fill": {
                    "displayName": "Fill",
                    "displayNameKey": "Visual_Fill",
                    "type": {
                        "fill": {
                            "solid": {
                                "color": true
                            }
                        }
                    }
                },
                "fillRule": {
                    "displayName": "Color saturation",
                    "displayNameKey": "Visual_ColorSaturation",
                    "type": {
                        "fillRule": {}
                    },
                    "rule": {
                        "inputRole": "Gradient",
                        "output": {
                            "property": "fill",
                            "selector": [
                                "Category"
                            ]
                        }
                    }
                }
            }
        },
        "categoryAxis": {
            "displayName": "X-Axis",
            "displayNameKey": "Visual_XAxis",
            "properties": {
                "show": {
                    "displayName": "Show",
                    "displayNameKey": "Visual_Show",
                    "type": {
                        "bool": true
                    }
                },
                "start": {
                    "displayName": "Start",
                    "displayNameKey": "Visual_Axis_Start",
                    "type": {
                        "numeric": true
                    }
                },
                "end": {
                    "displayName": "End",
                    "displayNameKey": "Visual_Axis_End",
                    "type": {
                        "numeric": true
                    }
                },
                "showAxisTitle": {
                    "displayName": "Title",
                    "displayNameKey": "Visual_Axis_Title",
                    "type": {
                        "bool": true
                    }
                },
                "axisColor": {
                    "displayName": "Color",
                    "displayNameKey": "Visual_Axis_LabelColor",
                    "type": {
                        "fill": {
                            "solid": {
                                "color": true
                            }
                        }
                    }
                },
                "labelDisplayUnits": {
                    "displayName": "Display units",
                    "displayNameKey": "Visual_DisplayUnits",
                    "type": {
                        "formatting": {
                            "labelDisplayUnits": true
                        }
                    }
                }
            }
        },
        "valueAxis": {
            "displayName": "Y-Axis",
            "displayNameKey": "Visual_YAxis",
            "properties": {
                "show": {
                    "displayName": "Show",
                    "displayNameKey": "Visual_Show",
                    "type": {
                        "bool": true
                    }
                },
                "start": {
                    "displayName": "Start",
                    "displayNameKey": "Visual_Axis_Start",
                    "type": {
                        "numeric": true
                    }
                },
                "end": {
                    "displayName": "End",
                    "displayNameKey": "Visual_Axis_End",
                    "type": {
                        "numeric": true
                    }
                },
                "showAxisTitle": {
                    "displayName": "Title",
                    "displayNameKey": "Visual_Axis_Title",
                    "type": {
                        "bool": true
                    }
                },
                "axisColor": {
                    "displayName": "Color",
                    "displayNameKey": "Visual_Axis_LabelColor",
                    "type": {
                        "fill": {
                            "solid": {
                                "color": true
                            }
                        }
                    }
                },
                "labelDisplayUnits": {
                    "displayName": "Display units",
                    "displayNameKey": "Visual_DisplayUnits",
                    "type": {
                        "formatting": {
                            "labelDisplayUnits": true
                        }
                    }
                }
            }
        },
        "legend": {
            "displayName": "Legend",
            "displayNameKey": "Visual_Legend",
            "properties": {
                "show": {
                    "displayName": "Show",
                    "displayNameKey": "Visual_Show",
                    "type": {
                        "bool": true
                    }
                },
                "position": {
                    "displayName": "Position",
                    "displayNameKey": "Visual_LegendPosition",
                    "description": "Select the location for the legend",
                    "descriptionKey": "Visual_Description_LegendPosition",
                    "type": {
                        "enumeration": [
                            {
                                "value": "Top",
                                "displayName": "Top",
                                "displayNameKey": "Visual_LegendPosition_Top"
                            },
                            {
                                "value": "Bottom",
                                "displayName": "Bottom",
                                "displayNameKey": "Visual_LegendPosition_Bottom"
                            },
                            {
                                "value": "Left",
                                "displayName": "Left",
                                "displayNameKey": "Visual_LegendPosition_Left"
                            },
                            {
                                "value": "Right",
                                "displayName": "Right",
                                "displayNameKey": "Visual_LegendPosition_Right"
                            },
                            {
                                "value": "TopCenter",
                                "displayName": "Top Center",
                                "displayNameKey": "Visual_LegendPosition_TopCenter"
                            },
                            {
                                "value": "BottomCenter",
                                "displayName": "Bottom Center",
                                "displayNameKey": "Visual_LegendPosition_BottomCenter"
                            },
                            {
                                "value": "LeftCenter",
                                "displayName": "Left Center",
                                "displayNameKey": "Visual_LegendPosition_LeftCenter"
                            },
                            {
                                "value": "RightCenter",
                                "displayName": "Right center",
                                "displayNameKey": "Visual_LegendPosition_RightCenter"
                            }
                        ]
                    }
                },
                "showTitle": {
                    "displayName": "Title",
                    "displayNameKey": "Visual_LegendShowTitle",
                    "description": "Display a title for legend symbols",
                    "descriptionKey": "Visual_Description_LegendShowTitle",
                    "type": {
                        "bool": true
                    }
                },
                "titleText": {
                    "displayName": "Legend Name",
                    "displayNameKey": "Visual_LegendName",
                    "description": "Title text",
                    "descriptionKey": "Visual_Description_LegendName",
                    "type": {
                        "text": true
                    }
                },
                "labelColor": {
                    "displayName": "Color",
                    "displayNameKey": "Visual_LegendTitleColor",
                    "type": {
                        "fill": {
                            "solid": {
                                "color": true
                            }
                        }
                    }
                },
                "fontSize": {
                    "displayName": "Text Size",
                    "displayNameKey": "Visual_TextSize",
                    "type": {
                        "formatting": {
                            "fontSize": true
                        }
                    }
                }
            }
        },
        "categoryLabels": {
            "displayName": "Category labels",
            "displayNameKey": "Visual_CategoryLabels",
            "properties": {
                "show": {
                    "displayName": "Show",
                    "displayNameKey": "Visual_Show",
                    "type": {
                        "bool": true
                    }
                },
                "color": {
                    "displayName": "Color",
                    "displayNameKey": "Visual_LabelsFill",
                    "type": {
                        "fill": {
                            "solid": {
                                "color": true
                            }
                        }
                    }
                },
                "fontSize": {
                    "displayName": "Text Size",
                    "displayNameKey": "Visual_TextSize",
                    "type": {
                        "formatting": {
                            "fontSize": true
                        }
                    }
                }
            }
        },
        "fillPoint": {
            "displayName": "Fill point",
            "displayNameKey": "Visual_FillPoint",
            "properties": {
                "show": {
                    "displayName": "Fill",
                    "displayNameKey": "Visual_Fill",
                    "type": {
                        "bool": true
                    }
                }
            }
        },
        "backdrop": {
            "displayName": "Backdrop",
            "displayNameKey": "Visual_Backdrop",
            "properties": {
                "show": {
                    "displayName": "Show",
                    "displayNameKey": "Visual_Show",
                    "type": {
                        "bool": true
                    }
                },
                "url": {
                    "displayName": "Image URL",
                    "displayNameKey": "Visual_Backdrop_ImageURL",
                    "type": {
                        "text": true
                    }
                }
            }
        },
        "crosshair": {
            "displayName": "Crosshair",
            "displayNameKey": "Visual_Crosshair",
            "properties": {
                "show": {
                    "displayName": "Crosshair",
                    "displayNameKey": "Visual_Crosshair",
                    "type": {
                        "bool": true
                    }
                }
            }
        },
        "outline": {
            "displayName": "Outline",
            "displayNameKey": "Visual_Outline",
            "properties": {
                "show": {
                    "displayName": "Outline",
                    "displayNameKey": "Visual_Outline",
                    "type": {
                        "bool": true
                    }
                }
            }
        }
    },
    "supportsMultiVisualSelection": true
}