import java.util.Random;
import org.knowm.xchart.HeatMapChart;
import org.knowm.xchart.HeatMapChartBuilder;
import org.knowm.xchart.SwingWrapper;
/**
* Basic HeatMap Chart
*
* Demonstrates the following:
*
*
* - Default Styler
*
- PlotContentSize = 1
*
- Show value
*/
public class xchart_heat {
public static void main(String[] args) {
HeatMapChart chart = getChart();
new SwingWrapper
(chart).displayChart();
}
static public HeatMapChart getChart() {
// Create Chart
HeatMapChart chart =
new HeatMapChartBuilder().width(1000).height(600).title("Basic HeatMap Chart").build();
chart.getStyler().setPlotContentSize(1);
chart.getStyler().setShowValue(true);
int[] xData = {1, 2, 3, 4};
int[] yData = {1, 2, 3};
int[][] heatData = new int[xData.length][yData.length];
Random random = new Random();
for (int i = 0; i < xData.length; i++) {
for (int j = 0; j < yData.length; j++) {
heatData[i][j] = random.nextInt(1000);
}
}
chart.addSeries("Basic HeatMap", xData, yData, heatData);
return chart;
}
}