code: private void drawHeatMap(Graphics2D chartGraphics, double[][] data) {
      // Calculate the available size for the heatmap.
      int noYCells = data.length;
      int noXCells = data[0].length;
  
      // double dataMin = min(data);
      // double dataMax = max(data);
  
      BufferedImage heatMapImage = new BufferedImage(heatMapSize.width, heatMapSize.height,
          BufferedImage.TYPE_INT_ARGB);
      Graphics2D heatMapGraphics = heatMapImage.createGraphics();
  
      for (int x = 0; x < noXCells; x++) {
        for (int y = 0; y < noYCells; y++) {
          // Set colour depending on zValues.
          heatMapGraphics.setColor(getCellColour(data[y][x], lowValue, highValue));
  
          int cellX = x * cellSize.width;
          int cellY = y * cellSize.height;
  
          heatMapGraphics.fillRect(cellX, cellY, cellSize.width, cellSize.height);
        }
      }
  
      // Draw the heat map onto the chart.
      chartGraphics.drawImage(heatMapImage, heatMapTL.x, heatMapTL.y, heatMapSize.width,
          heatMapSize.height, null);
    }
docs: /*
  Creates the actual heatmap element as an image, that can then be drawn onto a chart.