4 Replies Latest reply: May 10, 2012 6:32 AM by 912736 RSS

    LineChart and -fx-text-fill issue: how do I change the color of the labels

      Hello everyone,

      I'm currently facing an issue when I'm trying to style my LineChart with some CSS. Indeed I would like to change the color of the labels of my xAxis (CategoryAxis) and yAxis (NumberAxis) but it's not working.
      In my FXML file I tried to use the style attribute on my LineChart tag using: <LineChart style="-fx-text-fill: white"> with no result, the text remains black (even for the title of my chart). In order to know if the style attribute is well parsed I changed it to: style="-fx-background-color: red; -fx-text-fill: white;". The background is becoming red but the text still remains black.

      Finally I tried to define a stylesheet in my controller class with the same properties (red background and white text). My stylesheet is this one:
      .chart {
          -fx-text-fill: white;
          -fx-background-color: red;
      In my controller I do the following line in order to load my CSS file:
      Even with this option the text remains white, while the background becomes red.

      What I also tried is to put the -fx-text-file CSS property directly on my axises, but again it seems it is ignored.

      I followed the steps described in Figure 8-2 of this site: http://docs.oracle.com/javafx/2/charts/css-styles.htm

      Does anybody have an idea or encountered this issue?

      Thank you very much,

      PS: I'm using JFX 2.1 on MacOS X

      Edited by: twasyl on May 8, 2012 7:57 AM

      Edited by: twasyl on May 8, 2012 7:59 AM