3D Category Chart

General info on how to use the 3D Charting API can be found under '3D numerical chart'.

The data

A categorical representation is only possible for grid-based data. In terms of the API this means any class deriving WAbstractGridData. JWt already provides two implementations: WGridData and WEquidistantGridData. To create a categorical chart, the chart must be configured as such (by setting the type to CategoryChart) and the data which is added to this chart must be of the type BarSeries3D.

A categorical chart also allows multiple data series to be shown if the dimensions are the same. The different bar-series are then stacked on top of each other.

  void CatChart3d() {
    WContainerWidget container = new WContainerWidget();
    WCartesian3DChart chart = new WCartesian3DChart((WContainerWidget) container);
    chart.setRenderOptions(EnumSet.of(GLRenderOption.ClientSide, GLRenderOption.AntiAliasing));
    final WCssDecorationStyle style = new WCssDecorationStyle();
        new WBorder(BorderStyle.Solid, BorderWidth.Medium, new WColor(StandardColor.Black)));
    chart.resize(new WLength(800), new WLength(600));
    chart.setTitle("Fish consumption in western Europe");
    chart.axis(Axis.Z3D).setTitle("Consumption (pcs/year)");
    chart.setLegendStyle(new WFont(), new WPen(), new WBrush(new WColor(StandardColor.LightGray)));
    chart.setGridEnabled(Plane.XZ, Axis.Z3D, true);
    chart.setGridEnabled(Plane.YZ, Axis.Z3D, true);
    WStandardItemModel model = CsvUtil.csvToModel("" + "fish_consumption.csv", false);
    for (int i = 0; i < model.getRowCount(); i++) {
      for (int j = 0; j < model.getColumnCount(); j++) {
        if ((StringUtils.asString(model.getData(0, j))
                .equals(new WString("codfish").toString()))
            && (StringUtils.asString(model.getData(i, 0))
                .equals(new WString("Belgium").toString()))) {
          model.setData(i, j, new WColor(StandardColor.Cyan), ItemDataRole.MarkerBrushColor);
    WGridData isotopes = new WGridData(model);
    isotopes.setTitle("made-up data");
    chart.setAlternativeContent(new WImage(new WLink("pics/categoricalChartScreenshot.png")));