HeatMap with String values on axes

A discussion forum for JFreeChart (a 2D chart library for the Java platform).

HeatMap with String values on axes

Postby TEJASC » Wed Apr 23, 2014 8:17 am

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.
TEJASC
 
Posts: 10
Joined: Fri Mar 14, 2014 2:51 pm

Re: HeatMap with String values on axes

Postby david.gilbert » Thu Apr 24, 2014 1:55 pm

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.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Ask your company to buy the JFreeChart Developer Guide
:idea: Check out other products sold by my company Object Refinery Limited
david.gilbert
JFreeChart Project Leader
 
Posts: 11655
Joined: Fri Mar 14, 2003 10:29 am

Re: HeatMap with String values on axes

Postby TEJASC » Fri Apr 25, 2014 11:40 am

Thanks a lot.

I preferred first approach. It works like a charm. :P
TEJASC
 
Posts: 10
Joined: Fri Mar 14, 2014 2:51 pm

Re: HeatMap with String values on axes

Postby matinh » Thu Dec 14, 2017 10:41 pm

You can find a complete example, including a SymbolAxis on StackOverflow.
matinh
 
Posts: 483
Joined: Fri Aug 11, 2006 10:08 am
Location: Austria


Return to JFreeChart

Who is online

Users browsing this forum: Google [Bot] and 12 guests