1 2 Previous Next 16 Replies Latest reply: Nov 13, 2012 8:12 AM by 796425 Go to original post RSS
      • 15. Re: Render charts in background
        James_D
        MiPa: that's interesting, thanks for the info. I might experiment with that if I can generate some free time today.
        • 16. Re: Render charts in background
          796425
          Hello again,

          Just got a chance to try out your code, and it works great!

          EDIT: The below situation was fixed by setting chart.setAnimated(false); seems like the animation was happening after the snapshot was taken. Makes sense, although it wasn't easy to spot :)

          -----

          I am, however, bumping my head against the wall on one issue. Any charts that I export are missing the tick labels. I have tried updating the CSS and explicitly setting setTickLabelsVisible on both axis, but no matter what I try, the labels for both axes are missing. It seems that there are enough space left inside the chart for the labels to fit, but the labels are missing. I have also tried to explicitly set the fill color to black, but still no labels.

          As an experiment I tried generating the following chart, from the Ensemble application, but the exported charts are still missing the labels for some reason.

          String[] years = {"2007", "2008", "2009"};
                    CategoryAxis xAxis = new CategoryAxis();
          xAxis.setCategories(FXCollections.<String>observableArrayList(years));
          NumberAxis yAxis = new NumberAxis("Units Sold", 0.0d, 3000.0d, 1000.0d);
          ObservableList<BarChart.Series> barChartData = FXCollections.observableArrayList(
          new BarChart.Series("Apples", FXCollections.observableArrayList(
          new BarChart.Data(years[0], 567d),
          new BarChart.Data(years[1], 1292d),
          new BarChart.Data(years[2], 1292d)
          )),
          new BarChart.Series("Lemons", FXCollections.observableArrayList(
          new BarChart.Data(years[0], 956),
          new BarChart.Data(years[1], 1665),
          new BarChart.Data(years[2], 2559)
          )),
          new BarChart.Series("Oranges", FXCollections.observableArrayList(
          new BarChart.Data(years[0], 1154),
          new BarChart.Data(years[1], 1927),
          new BarChart.Data(years[2], 2774)
          ))
          );
          BarChart chart = new BarChart(xAxis, yAxis, barChartData, 25.0d);
          chart.getXAxis().setTickLabelsVisible(true);
          chart.getYAxis().setTickMarkVisible(true);

          The result is as follows:

          http://stuff.haagen.name/missingTicklabels.png

          But if I render that very same chart and display it the application, those tick labels are visible.

          Any suggestions ?

          Edited by: Joachimhs on Nov 13, 2012 3:10 PM
          1 2 Previous Next