具有矩阵数据映射的PowerBI自定义DataGrid

时间:2019-07-04 21:56:33

标签: powerbi powerbi-custom-visuals

我已经创建了这个ag-grid的自定义视觉包装器,作为对自定义视觉开发的首次尝试/研究

https://gitlab.com/nite2/powerbi-ag-grid

当前仅是使用表数据映射而已,这几乎是准系统-不允许仪表板开发人员控制ag-grid提供的强大行分组和数据透视。我在使用矩阵数据映射时遇到了麻烦,但是显然是在没有考虑开放社区自定义视觉开发人员的情况下构建的,例如缺少文档和类似这样的帖子:

https://community.powerbi.com/t5/Developer/Need-Help-understanding-Matrix-dataMapping/td-p/225967

谁能建议一个体面的资源来快速理解矩阵映射,所以我可以将其映射到简单而有用的ag-grid消费形式(以ag-grid ColumnDefs的形式)?还是矩阵数据映射自定义的另一个开源示例,也就是对矩阵dataview进行一些javascript操作的示例?

如果添加网格(发布到gitlab中的dist文件夹中),那么您应该在网格本身中看到一个列侧边栏,这应该允许您使用网格枢轴,或者只是转到https://www.ag-grid.com/example.php < / p>

(相关:我似乎也无法登录https://community.powerbi.com,在它和https://login.microsoftonline.com之间进行无限重定向-尝试了所有浏览器,OSX和Windows-清除了两者上的所有cookie,并关闭了任何广告块且不跟踪-有任何建议吗?)

1 个答案:

答案 0 :(得分:0)

这是我编写的capability.json的示例,用于将矩阵映射到Power Bi的四个输入(两个作为分组;两个作为度量):

{
"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
                        }
                    ]
                }
            }
        }
    }],

"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

}