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.

source
  void CatChart3d() {
    WContainerWidget container = new WContainerWidget();
    WCartesian3DChart chart = new WCartesian3DChart((WContainerWidget) container);
    chart.setType(ChartType.Category);
    chart.setRenderOptions(EnumSet.of(GLRenderOption.ClientSide, GLRenderOption.AntiAliasing));
    final WCssDecorationStyle style = new WCssDecorationStyle();
    style.setBorder(
        new WBorder(BorderStyle.Solid, BorderWidth.Medium, new WColor(StandardColor.Black)));
    chart.setDecorationStyle(style);
    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.setLegendEnabled(true);
    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))
                .toString()
                .equals(new WString("codfish").toString()))
            && (StringUtils.asString(model.getData(i, 0))
                .toString()
                .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");
    isotopes.setType(Series3DType.Bar);
    chart.addDataSeries(isotopes);
    chart.setAlternativeContent(new WImage(new WLink("pics/categoricalChartScreenshot.png")));
  }