Can I have a HeatMap in JFree similar to this.
Which dataset should I use? I tried using DefaultHeatMapDataset and DefaultXYZDataset but they supports only numeric values on its axes and not String values.
Can I use DefaultCategoryDataset to implement HeatMap?
Suggestions are appreciated.
Thanks in advance.
HeatMap with String values on axes
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Re: HeatMap with String values on axes
It's not ideal, but you could try the SymbolAxis class (which displays strings in place of integer values).
A better approach (but requiring a lot more coding) would be to store the data in a CategoryDataset (it perfectly matches this numeric table structure) then create a new plot class (it could be called GridPlot or TablePlot) that has ordinal axes (CategoryAxis) for both the x-axis and the y-axis. A renderer for this plot would use the row and column keys to lookup the axes for the coordinates of the cell to be rendered, then "paint" this cell. The existing PaintScale code (LookupPaintScale) could be reused to determine the color used for the fill. The item labeling mechanism could be copied to display the values.
A better approach (but requiring a lot more coding) would be to store the data in a CategoryDataset (it perfectly matches this numeric table structure) then create a new plot class (it could be called GridPlot or TablePlot) that has ordinal axes (CategoryAxis) for both the x-axis and the y-axis. A renderer for this plot would use the row and column keys to lookup the axes for the coordinates of the cell to be rendered, then "paint" this cell. The existing PaintScale code (LookupPaintScale) could be reused to determine the color used for the fill. The item labeling mechanism could be copied to display the values.
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
Re: HeatMap with String values on axes
Thanks a lot.
I preferred first approach. It works like a charm.
I preferred first approach. It works like a charm.
Re: HeatMap with String values on axes
You can find a complete example, including a SymbolAxis on StackOverflow.