I am using Vega Lite in Power BI's Visual deneb 1.5.1.0 and i encountered a problem with cornerRadiusEnd. If i have negative values on the x-axis, the end of my bar is on the left, not on the right. But the corner-radius is still on the right side and that imo is not correct. You can see it in the picture: Image of the result
Expected behaviour: When there is a negative value on x-axis, I would expect the round corners to be on the left side of the bar and when the values are positive, the round corners should be on the right side.
Here you can download the Power BI-file: https://github.com/deneb-viz/deneb/files/11704465/DENEB_Problem.zip
My line in Code:
"mark":{"type":"bar","size":30,"strokeWidth":4,"cornerRadiusEnd":15}
As a workaround(!) i tried this with no error, but always a resulting radius of 5 (the else-case):
"mark":{"type":"bar","size":30,"strokeWidth":4,"cornerRadiusEnd": {"expr": "if(datum.Netto<=0,0,5)"}}
The only way i found to access the dataset from the mark was this, but this is bound to a fixed row, so not dynamic:
"mark":{"type":"bar","size":30,"strokeWidth":4,"cornerRadiusEnd": {"expr": "if(data('dataset')[0]['Netto']<=0,0,5)"}}
Here is my full code:
{
"data":{"name":"dataset"},
"height":{"step":70},
"layer":[
{
"mark":{"type":"bar","color":"#e6e6e6","size":40},
"encoding":{"y":{"field":"Produkt","axis":{"labelAngle":0},"title":null},"x":{"field":"Wochenziel","type":"quantitative","title":null}}
},
{
"mark":{"type":"bar","color":"#f1f1f1","size":50},
"encoding":{"y":{"field":"Produkt","axis":{"labelAngle":0},"title":null},"x":{"field":"Tagesziel","type":"quantitative","title":null}}
},
{
"mark":{"type":"bar","color":"#edc947","size":50,"stroke":"#bda03a","strokeWidth":2},
"encoding":{"y":{"field":"Produkt","axis":{"labelAngle":0},"title":null},"x":{"field":"Storno","type":"quantitative","title":null}}
},
{
"mark":{"type":"bar","size":30,"strokeWidth":4,"cornerRadiusEnd": 15},
"encoding":{"y":{"field":"Produkt","axis":{"labelAngle":0},"title":null},"x":{"field":"Netto","type":"quantitative","title":null},"color":{"field":"BalkenCol","type": "nominal","scale": null},"stroke":{"field":"BalkenBrdCol","type": "nominal","scale": null}}
},
{
"mark":{"type":"tick","color":"#E20074","thickness":4,"size":50,"dy":-20},
"encoding":{"y":{"field":"Produkt","axis":{"labelAngle":0},"title":null},"x":{"field":"Wochenziel","type":"quantitative","title":null}}
},
{
"mark":{"type":"circle","color":"#E20074","size":90,"yOffset":-25},
"encoding":{"y":{"field":"Produkt","axis":{"labelAngle":0},"title":null},"x":{"field":"Wochenziel","type":"quantitative","title":null}}
},
{
"mark":{"type":"tick","color":"#999999","thickness":3,"size":45},
"encoding":{"y":{"field":"Produkt","axis":{"labelAngle":0},"title":null},"x":{"field":"Tagesziel","type":"quantitative","title":null}}
},
{
"mark":{"type":"text","size":15,"align":"right","dx":-5},
"encoding":{
"y":{"field":"Produkt","axis":{"labelAngle":0},"title":null}
,"text":{"field":"Netto","type":"quantitative"},"color":{"condition":{"test":{"field":"Netto","lte":0},"value":"black"},"value":"white"},"x":{"field":"Netto","type":"quantitative","title":null}}
},
{
"mark":{"type":"text","color":"#777777","size":11,"dx":0,"dy":30},
"encoding":{"y":{"field":"Produkt","axis":{"labelAngle":0},"title":null},"text":{"field":"Tagesziel","type":"quantitative"},"x":{"field":"Tagesziel","type":"quantitative","title":null}}
},
{
"mark":{"type":"text","color":"#E20074","size":11,"dx":0,"dy":32},
"encoding":{"y":{"field":"Produkt","axis":{"labelAngle":0},"title":null},"text":{"field":"Wochenziel","type":"quantitative"},"x":{"field":"Wochenziel","type":"quantitative","title":null}}
}
]
}
In case of negative values the cornerRadiusEnd should be left in a horizontal bar chart.