Azure Workbook柱状图无法显示,提示缺少合适列的问题求助
Azure Workbook柱状图报错:"Could not find appropriate columns for Bar chart" 解决方案
问题背景
需要在Azure Workbook中查询指定资源组(RG1-RG5)当月至今的虚拟机按需/Spot实例成本,以柱状图按资源组展示两类成本。当前网格视图数据正常,但切换为柱状图时触发错误提示:Could not find appropriate columns for Bar chart。
当前使用的JSON配置:
{ "type": "Usage", "timeframe": "MonthToDate", "dataset": { "granularity": "Monthly", "aggregation": { "totalCost": { "name": "PreTaxCost", "function": "Sum" } }, "filter": { "and": [ { "dimensions": { "name": "ResourceGroup", "operator": "In", "values": [ "RG1", "RG2", "RG3", "RG4", "RG5" ] } }, { "dimensions": { "name": "ServiceName", "operator": "In", "values": [ "Virtual Machines" ] } } ] }, "grouping": [ { "type": "Dimension", "name": "ResourceGroup" }, { "type": "Dimension", "name": "PricingModel" } ], "visualization": { "chartType": "BarChart", "title": "Cost by Resource Group", "legend": "show" } } }
问题原因
原配置的visualization块仅指定了图表类型和标题,但未明确柱状图所需的轴映射规则——Azure Workbook无法自动识别哪个字段作为类别轴、数值轴和系列拆分字段。
修改方案
在visualization节点中添加category、value和series配置,明确各字段的作用:
修改后的完整配置:
{ "type": "Usage", "timeframe": "MonthToDate", "dataset": { "granularity": "Monthly", "aggregation": { "totalCost": { "name": "PreTaxCost", "function": "Sum" } }, "filter": { "and": [ { "dimensions": { "name": "ResourceGroup", "operator": "In", "values": [ "RG1", "RG2", "RG3", "RG4", "RG5" ] } }, { "dimensions": { "name": "ServiceName", "operator": "In", "values": [ "Virtual Machines" ] } } ] }, "grouping": [ { "type": "Dimension", "name": "ResourceGroup" }, { "type": "Dimension", "name": "PricingModel" } ], "visualization": { "chartType": "BarChart", "title": "Cost by Resource Group", "legend": "show", // 新增轴映射配置 "category": { "column": "ResourceGroup" }, "value": { "column": "totalCost" }, "series": { "column": "PricingModel" } } } }
修改说明
category: 指定ResourceGroup为X轴类别,每个资源组对应一个分组value: 指定totalCost为Y轴数值,展示成本金额series: 指定PricingModel为系列拆分,每个资源组下生成两个柱子分别对应Spot和按需实例的成本
修改后即可正常渲染符合预期的柱状图。
内容的提问来源于stack exchange,提问作者Ali
相关产品推荐
相关产品推荐

