JavaFX CSS 警告:CSS 解析文件时出错:...:预期的 LBRACE 位于
JavaFX CSS WARNING: CSS Error parsing file : ... : Expected LBRACE at
我最近问了一个关于在 JavaFX LineChart 上添加两条垂直线的问题,现在我在将一些样式内容应用到绘图时遇到了问题。我认为这是一个新问题,所以我打开一个新线程。
我的问题:如何改变系列的不同颜色?我也想把背景改成白色。
以下是我创建的图表(它扩展了 LineChart):
LineChartWithMarkers<Number, Number> chart = new LineChartWithMarkers<Number, Number>(xAxis, yAxis, dataset);
xAxis.setLabel("time(s)");
yAxis.setLabel("deg/s");
chart.setStyle(".chart-series-line { -fx-stroke-width: 2px; -fx-effect: null; ");
chart.setStyle(".default-color0.chart-series-line { -fx-stroke: blue; }");
chart.setStyle(".default-color1.chart-series-line { -fx-stroke: red; }");
chart.setStyle(".default-color0.chart-line-symbol { -fx-stroke: blue, blue; }");
chart.setStyle(".default-color1.chart-line-symbol { -fx-stroke: red, red; }");
chart.setStyle(".chart-legend { -fx-background-color: transparent; }");
出于某种原因,这些代码不适用于图表。所以我尝试使用 CSS 文件。
以下是CSS文件:
@CHARSET "ISO-8859-1";
.chart-series-line {
-fx-stroke-width: 1px;
-fx-effect: null;}
.default-color0.chart-series-line { -fx-stroke: blue; }
.default-color1.chart-series-line { -fx-stroke: red; }
.default-color0.chart-line-symbol { -fx-background-color: blue, blue; }
.default-color1.chart-line-symbol { -fx-background-color: red, red; }
.chart-legend {
-fx-background-color: transparent;
-fx-font-size: 0.75em;}
.chart-legend-item-symbol{
-fx-background-radius: 2;}
.chart-plot-background {
-fx-background-color: transparent;}
我尝试遵循 Using JavaFX Charts: Styling Charts with CSS,但我在控制台中得到的错误是 "WARNING: CSS Error parsing file : ... : Expected LBRACE at [1,9]"
我今天刚从 JDK 7 切换到 JDK 8,所以我不确定这是否与此有关...
感谢您的帮助!
@charset rule is not supported by JavaFX CSS,它只是完整 W3C CSS 的一个子集。尝试删除它。
@ Rules
Beginning with JavaFX 8u20, the CSS @import is also partially
supported. Only unconditional import is supported. In other words, the
media‑type qualifier is not supported. Also, the JavaFX CSS parser is
non-compliant with regard to where an @import may appear within a
stylesheet (see At‑rules). Users are cautioned that this will be fixed
in a future release. Adherence to the W3C standard is strongly
advised.
我最近问了一个关于在 JavaFX LineChart 上添加两条垂直线的问题,现在我在将一些样式内容应用到绘图时遇到了问题。我认为这是一个新问题,所以我打开一个新线程。
我的问题:如何改变系列的不同颜色?我也想把背景改成白色。
以下是我创建的图表(它扩展了 LineChart):
LineChartWithMarkers<Number, Number> chart = new LineChartWithMarkers<Number, Number>(xAxis, yAxis, dataset);
xAxis.setLabel("time(s)");
yAxis.setLabel("deg/s");
chart.setStyle(".chart-series-line { -fx-stroke-width: 2px; -fx-effect: null; ");
chart.setStyle(".default-color0.chart-series-line { -fx-stroke: blue; }");
chart.setStyle(".default-color1.chart-series-line { -fx-stroke: red; }");
chart.setStyle(".default-color0.chart-line-symbol { -fx-stroke: blue, blue; }");
chart.setStyle(".default-color1.chart-line-symbol { -fx-stroke: red, red; }");
chart.setStyle(".chart-legend { -fx-background-color: transparent; }");
出于某种原因,这些代码不适用于图表。所以我尝试使用 CSS 文件。
以下是CSS文件:
@CHARSET "ISO-8859-1";
.chart-series-line {
-fx-stroke-width: 1px;
-fx-effect: null;}
.default-color0.chart-series-line { -fx-stroke: blue; }
.default-color1.chart-series-line { -fx-stroke: red; }
.default-color0.chart-line-symbol { -fx-background-color: blue, blue; }
.default-color1.chart-line-symbol { -fx-background-color: red, red; }
.chart-legend {
-fx-background-color: transparent;
-fx-font-size: 0.75em;}
.chart-legend-item-symbol{
-fx-background-radius: 2;}
.chart-plot-background {
-fx-background-color: transparent;}
我尝试遵循 Using JavaFX Charts: Styling Charts with CSS,但我在控制台中得到的错误是 "WARNING: CSS Error parsing file : ... : Expected LBRACE at [1,9]"
我今天刚从 JDK 7 切换到 JDK 8,所以我不确定这是否与此有关...
感谢您的帮助!
@charset rule is not supported by JavaFX CSS,它只是完整 W3C CSS 的一个子集。尝试删除它。
@ Rules
Beginning with JavaFX 8u20, the CSS @import is also partially supported. Only unconditional import is supported. In other words, the media‑type qualifier is not supported. Also, the JavaFX CSS parser is non-compliant with regard to where an @import may appear within a stylesheet (see At‑rules). Users are cautioned that this will be fixed in a future release. Adherence to the W3C standard is strongly advised.