笔划宽度 javafx 折线图的异常行为
Unusual behaviour of stroke-width javafx line-charts
我将折线图用作条形图(由于某些原因),并以像素为单位动态设置线(条)笔画宽度。但似乎增加线的笔画宽度,也增加了它的长度,这不是预期的。
Both are programmatically set to T1,10 and T2,30
此代码负责根据 x 轴上的项目数动态设置线条 stroke-width。
private void setGreenBar(Node node, double barWidth){
node.setStyle("-fx-stroke: greenyellow; -fx-stroke-width: " + barWidth + "px;");
}
private void setRedBar(Node node, double barWidth){
node.setStyle("-fx-stroke: red; -fx-stroke-width: " + barWidth + "px;");
}
我没有测试过,但我猜这是由于笔画线帽。默认值为 SQUARE,但在您的情况下,BUTT 将是一个选择。
-fx-stroke-line-cap: butt
我将折线图用作条形图(由于某些原因),并以像素为单位动态设置线(条)笔画宽度。但似乎增加线的笔画宽度,也增加了它的长度,这不是预期的。
Both are programmatically set to T1,10 and T2,30
此代码负责根据 x 轴上的项目数动态设置线条 stroke-width。
private void setGreenBar(Node node, double barWidth){
node.setStyle("-fx-stroke: greenyellow; -fx-stroke-width: " + barWidth + "px;");
}
private void setRedBar(Node node, double barWidth){
node.setStyle("-fx-stroke: red; -fx-stroke-width: " + barWidth + "px;");
}
我没有测试过,但我猜这是由于笔画线帽。默认值为 SQUARE,但在您的情况下,BUTT 将是一个选择。
-fx-stroke-line-cap: butt