Class HeatmapSeries
A heatmap: a grid of cells coloured by value. Column c sits at x = c and row r at y = r,
so pair it with a CategoryAxis on each axis to name the columns and rows.
Chart chart = new Chart();
double[][] values = {{3, 8, 5}, {6, 9, 4}, {2, 7, 8}};
chart.setXAxis(new CategoryAxis(Axis.BOTTOM, "Mon", "Tue", "Wed"));
chart.setYAxis(new CategoryAxis(Axis.LEFT, "Morning", "Noon", "Evening"));
chart.addSeries(new HeatmapSeries("Visits").setMatrix(values));

-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidRecords a zero baseline as the start of the entry animation.protected voidRecords the values currently on screen as the start of the next transition.intcellId(int row, int column) The hit point id of a cell,row * getColumns() + column, which never aliases however wide the matrix is.voidcollectTableRows(List<String[]> rows) Adds this series' data to an accessible table, one{series, item, value}row per point.formatTooltip(ChartContext ctx, ChartPoint p) The tooltip row for a point: the series or point name and its formatted value.formatValue(ChartContext ctx, double value) Formats a value for a label or tooltip.intThe number of columns.getPoint(ChartContext ctx, int index) The point atindexfor a shared tooltip, or null.intEvery cell is a point, numbered row by row ascellId(row, column), so a selection or a tooltip survives a repaint andChart.selectcan name a cell.intgetRows()The number of rows.doublegetValue(int row, int column) The value of a cell.double[]The range of values the colour scale spans: the fixed range when one is set, otherwise the smallest and largest value present.double[]The extent of the data along x,{min, max}, or null when empty or not cartesian.double[]getXBoundsWithin(double maxX) The extent along x of the data at or belowmaxX,{min, max}, or null when none is.double[]The extent of the data along y,{min, max}, or null when empty or not cartesian.hitTest(ChartContext ctx, int x, int y, int radius) Finds the data point nearest a screen position.booleanTrue for series drawn against x and y axes; false for pies, treemaps and other series that fill the plot themselves.voidpaint(ChartContext ctx) Paints the series.voidpaintLegendSymbol(Graphics g, int x, int y, int size) Paints the legend swatch.setColorScale(ColorScale scale) The colour scale; by default a sequential scale of the series colour.setMatrix(double[][] values) Replaces the values, animated.setScaleRange(double min, double max) Fixes the values mapped to the ends of the scale instead of the data's extent.Methods inherited from class Series
attached, dataChanged, detached, getChart, getColor, getLegendEntryCount, getLegendEntryName, getName, getSelectablePointCount, getValueFormatter, getVisibilityFraction, handleTap, isGap, isLegendEntryVisible, isPointCountFromLayout, isSecondaryAxis, isShowValues, isVisible, lerp, paintLegendEntrySymbol, repaintChart, setColor, setName, setSecondaryAxis, setShowValues, setValueFormatter, setVisible, toggleLegendEntry, transitionEnded
-
Constructor Details
-
HeatmapSeries
Creates an empty heatmap.
Parameters
name: the series name
-
-
Method Details
-
isCartesian
public boolean isCartesian()Description copied from class:SeriesTrue for series drawn against x and y axes; false for pies, treemaps and other series that fill the plot themselves.- Specified by:
isCartesianin classSeries
-
setMatrix
Replaces the values, animated.
Parameters
values:values[row][column];NaNleaves a cell empty
Returns
this series
-
getValue
public double getValue(int row, int column) The value of a cell. -
getRows
public int getRows()The number of rows. -
getColumns
public int getColumns()The number of columns. -
setColorScale
The colour scale; by default a sequential scale of the series colour.
Parameters
scale: the scale
Returns
this series
-
setScaleRange
Fixes the values mapped to the ends of the scale instead of the data's extent.
Parameters
-
min: the value at the low end -
max: the value at the high end
Returns
this series
-
-
getValueRange
public double[] getValueRange()The range of values the colour scale spans: the fixed range when one is set, otherwise the smallest and largest value present. A matrix with no values at all answers
{0, 1}.Returns
a new
{min, max}array -
cellId
public int cellId(int row, int column) The hit point id of a cell,
row * getColumns() + column, which never aliases however wide the matrix is.Parameters
-
row: the row -
column: the column
Returns
the id
hitTestgives that cell's point -
-
getXBounds
public double[] getXBounds()Description copied from class:SeriesThe extent of the data along x,{min, max}, or null when empty or not cartesian.- Overrides:
getXBoundsin classSeries
-
getXBoundsWithin
public double[] getXBoundsWithin(double maxX) Description copied from class:SeriesThe extent along x of the data at or below
maxX,{min, max}, or null when none is. A category axis with no labels asks for this to leave a far outlier out of its bands.Parameters
maxX: the largest x that counts
Returns
the bounds of the points that count, or null
- Overrides:
getXBoundsWithinin classSeries
-
getYBounds
public double[] getYBounds()Description copied from class:SeriesThe extent of the data along y,{min, max}, or null when empty or not cartesian.- Overrides:
getYBoundsin classSeries
-
captureTransitionStart
protected void captureTransitionStart()Description copied from class:SeriesRecords the values currently on screen as the start of the next transition. Called by the chart before data changes; a subclass with animated data overrides it.- Overrides:
captureTransitionStartin classSeries
-
captureEntryStart
protected void captureEntryStart()Description copied from class:SeriesRecords a zero baseline as the start of the entry animation.- Overrides:
captureEntryStartin classSeries
-
paint
Description copied from class:SeriesPaints the series.
Parameters
ctx: the current frame: graphics, plot area, axes and animation progress
-
paintLegendSymbol
Description copied from class:SeriesPaints the legend swatch.
Parameters
-
g: graphics -
x: swatch left -
y: swatch top -
size: swatch size
- Overrides:
paintLegendSymbolin classSeries
-
-
getPointCount
public int getPointCount()Every cell is a point, numbered row by row ascellId(row, column), so a selection or a tooltip survives a repaint andChart.selectcan name a cell.- Overrides:
getPointCountin classSeries
-
getPoint
Description copied from class:SeriesThe point atindexfor a shared tooltip, or null. -
hitTest
Description copied from class:SeriesFinds the data point nearest a screen position.
Parameters
-
ctx: the frame the series was last painted in -
x: chart relative x -
y: chart relative y -
radius: how far from the point a touch may land and still hit it
Returns
the point, or null
-
-
formatValue
Description copied from class:SeriesFormats a value for a label or tooltip.- Overrides:
formatValuein classSeries
-
formatTooltip
Description copied from class:SeriesThe tooltip row for a point: the series or point name and its formatted value. Series with several values per point (open/high/low/close, ranges, box plots) override this.
Parameters
-
ctx: the last paint context -
p: the point
Returns
one line of text
- Overrides:
formatTooltipin classSeries
-
-
collectTableRows
Description copied from class:SeriesAdds this series' data to an accessible table, one
{series, item, value}row per point. Used byChart.toTable()and the chart's accessibility text.Parameters
rows: the list to append rows to
- Overrides:
collectTableRowsin classSeries
-