Details
-
Bug
-
Resolution: Fixed
-
P3
-
8u20
Description
I've tried to draw a simple AreaChart with a series of negative values. In Java 7 the area between the line and the X-Axis will be filled. In java 8 the area between the line and the bottom of the chart will be filled. Are there any new properties which have to set to draw it in the correct way? I've checked it with the stackedAreaChart. Here everything is fine in Java7 and Java8.
{code:title=Area Chart|borderStyle=solid}
package linechartsample;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.chart.AreaChart;
import javafx.scene.chart.NumberAxis;
import javafx.stage.Stage;
public class StackedAreaChartDemo extends Application {
int[] values1 = new int[] { -5, -10, -20, -10, -50, 10, -80, -60, -20, -30, -5 };
@Override
public void start(Stage stage) {
stage.setTitle("Line Chart Sample");
final NumberAxis xAxis = new NumberAxis();
final NumberAxis yAxis = new NumberAxis();
xAxis.setLabel("Month");
final AreaChart<Number, Number> lineChart = new AreaChart<Number, Number>(xAxis, yAxis);
lineChart.setTitle("Area Chart Java 7");
AreaChart.Series<Number, Number> series1 = new AreaChart.Series<Number, Number>();
series1.setName("Portfolio 1");
for (int i = 0; i < 10; i++) {
series1.getData().add(new AreaChart.Data<Number, Number>(i + 1, values1[i]));
}
Scene scene = new Scene(lineChart, 800, 600);
lineChart.getData().addAll(series1);
StringBuilder builder = new StringBuilder();
builder.append("-fx-fill: ");
builder.append("#");
builder.append(Integer.toHexString(105));
builder.append(Integer.toHexString(105));
builder.append(Integer.toHexString(105));
builder.append(Integer.toHexString(100));
series1.getNode().lookup(".chart-series-area-fill").setStyle(builder.toString());
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
{code}
{code:title=Area Chart|borderStyle=solid}
package linechartsample;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.chart.AreaChart;
import javafx.scene.chart.NumberAxis;
import javafx.stage.Stage;
public class StackedAreaChartDemo extends Application {
int[] values1 = new int[] { -5, -10, -20, -10, -50, 10, -80, -60, -20, -30, -5 };
@Override
public void start(Stage stage) {
stage.setTitle("Line Chart Sample");
final NumberAxis xAxis = new NumberAxis();
final NumberAxis yAxis = new NumberAxis();
xAxis.setLabel("Month");
final AreaChart<Number, Number> lineChart = new AreaChart<Number, Number>(xAxis, yAxis);
lineChart.setTitle("Area Chart Java 7");
AreaChart.Series<Number, Number> series1 = new AreaChart.Series<Number, Number>();
series1.setName("Portfolio 1");
for (int i = 0; i < 10; i++) {
series1.getData().add(new AreaChart.Data<Number, Number>(i + 1, values1[i]));
}
Scene scene = new Scene(lineChart, 800, 600);
lineChart.getData().addAll(series1);
StringBuilder builder = new StringBuilder();
builder.append("-fx-fill: ");
builder.append("#");
builder.append(Integer.toHexString(105));
builder.append(Integer.toHexString(105));
builder.append(Integer.toHexString(105));
builder.append(Integer.toHexString(100));
series1.getNode().lookup(".chart-series-area-fill").setStyle(builder.toString());
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
{code}
Attachments
Issue Links
- duplicates
-
JDK-8081715 JavaFX Area Chart not rendering properly negative values
-
- Closed
-
- relates to
-
JDK-8122347 AreaChart fills the area above the chart when y axis starts with value bigger than 0
-
- Resolved
-