0

I need a area chart that can stylize the chart fill in a different color (red, e.g.) when this be negative.

How to do it in JavaFX?

https://i.stack.imgur.com/SSl5a.png

https://i.stack.imgur.com/nzag3.png

Samuel
  • 33
  • 4

1 Answers1

0

I think the easiest way to achieve this is to create two XYCHartSeries for your Chart. One for the negative values and one for the positives. Then you can set the color of the ChartSeries with CSS like this: positiveChart.setId("positiveValues"); positiveChart.setStyle("#positiveValues {-fx-bar-fill: #4CAF50 }");

grahan
  • 2,148
  • 5
  • 29
  • 43
  • I even thought about it, but at the chart remain the same as the previous example I need to find out the exact location of the intersection of the series on the x axis. – Samuel Sep 02 '15 at 12:09
  • Maybe u can iterate through the data of your chart. Something like this: for(int i = 0 ; i < xyChartSeries.getData().size(); i++){ System.out.println(xyseries1.getData().get(i)); } and then apply the css for each data in this loop ? – grahan Sep 02 '15 at 12:33
  • In this way I could change only the symbols of negative values. For the line and the fill change occurs for the entire series. – Samuel Sep 03 '15 at 11:40