如何在JavaFX 2.0中将点在散点图上居中? [英] How can I center the dots on a scatter chart in JavaFX 2.0?

查看:75
本文介绍了如何在JavaFX 2.0中将点在散点图上居中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用JavaFX 2.0散点图时,绘制的点以点的左上角接触点而不是点的中心为点的方式绘制.因此,与其看起来像是在点(1,1)上绘制,不如看起来像是在(1.1,0.9)上.有人知道如何解决这个问题吗?

When using the JavaFX 2.0 scatter chart the plotted dots are graphed with the top left corner of the dot touching the point rather than the center of the dot on the point. So rather than it looking like it is plotting at the point (1, 1) it looks more like it's at (1.1, 0.9). Does anyone know how to fix this?

推荐答案

ScatterChart绘制移动绘制的点的方式存在一个错误.

There is a bug in a way ScatterChart draws shifting plotted dots.

在解决此问题之前,您可以覆盖点样式类.要执行该操作,请将新文件"style.css"添加到与您的主类和下一个内容相同的包中:

Until fix as a workaround you can override dots style class. To perform that add new file "style.css" to the same package with your main class and next content:

.chart-symbol { /* solid circle */
    -fx-background-color: #f9d900;
    -fx-background-radius: 5px;
    -fx-translate-x: -4px;
    -fx-translate-y: -4px;
}

在创建主场景的代码中添加下一行:

In the code where your main scene is created add next line:

scene.getStylesheets().add("style.css");

这篇关于如何在JavaFX 2.0中将点在散点图上居中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆