JavaFx 2.x: XYChart properties

∥☆過路亽.° 提交于 2019-12-06 13:40:45
jewelsea

Yes, your case is simpler in logic than How to dynamically change line style in JavaFX 2.0 line chart? and you are also asking for a couple more features. Marking as duplicate was just an easy way to point to a similar question and answer.

I think the answer is the same (use css lookups) - there is no such api in JavaFX 2.2 as lineChart.setStroke.

Eventually some of the stuff which is only accessible via css lookups might be made available via Java API. For instance some of the region background stuff is API in JavaFX 8 so, once you get a reference to it, you could modify it via api - though, even then, I still don't think there is a way to get a reference to something like a chart background without a css lookup or some unthinkably ugly sequence of getChildren().get(idx) calls or hacking into the chart source code. Of those options, I think the css lookup approach is the most preferable most of the time.

Note that you are not really avoiding a css file, as JavaFX 2.2 ships with a default css file which is used to style charts. Also note that the linked sample solution to the dynamic line style question does not supply a user stylesheet - all user styling is done in code.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!