以下是国内外AI常见的对比图:
来源https://api-docs.deepseek.com/zh-cn/news/news250528
这种条纹填充效果Power BI十几行度量值也可以轻松模拟。原理是DAX结合HTML。
图表度量值如下:
M.P.条形图.斜线纹理 =
VAR MaxValue = MAXX(ALLSELECTED('店铺资料'[城市]), [M.销售业绩])
VAR BarWidth = [M.销售业绩] / MaxValue * 100
VAR LabelPosition = IF(BarWidth > 90, BarWidth - 10, BarWidth)
RETURN
"<div id='wujunmin' style='display: flex; align-items: center; margin-bottom: 8px; height: 30px; overflow: visible;'>
<div style='font-size: 14px; padding-right: 10px; white-space: nowrap;'>" &
SELECTEDVALUE('店铺资料'[城市]) &
"</div>
<div style='flex-grow: 1; position: relative; min-width: 0;'>
<div style='background: repeating-linear-gradient(45deg, rgb(102,130,252) 0, rgb(102,130,252) 8px, snow 8px, snow 10px);
width: " & BarWidth & "%; height: 24px; border-radius: 2px;'></div>
<div style='position: absolute; left: " & LabelPosition & "%; top: 0; font-size: 14px; padding-left: 5px; line-height: 24px; white-space: nowrap;'>" &
FORMAT([M.销售业绩], "#,#") &
"</div>
</div>
</div>"
度量值放入HTML Content视觉对象使用:
核心环节在于这一句:
repeating-linear-gradient(45deg, rgb(102,130,252) 0, rgb(102,130,252) 8px, snow 8px, snow 10px);
斜角45度的渐变产生条纹的视觉。background这里可以添加条件判断,当最高值时返回条纹,否则常规颜色:
也可以略修改变为柱形图:
更多Power BI SVG、HTML可视化可以访问我的github主页: