diff --git a/src/chart/heatmap/HeatmapSeries.ts b/src/chart/heatmap/HeatmapSeries.ts index af831ef135..3e4b373143 100644 --- a/src/chart/heatmap/HeatmapSeries.ts +++ b/src/chart/heatmap/HeatmapSeries.ts @@ -52,6 +52,7 @@ export interface HeatmapDataItemOption extends HeatmapStateOption, StatesOptionM export interface HeatmapSeriesOption extends SeriesOption, HeatmapStateOption, SeriesOnCartesianOptionMixin, SeriesOnGeoOptionMixin, SeriesOnCalendarOptionMixin, SeriesEncodeOptionMixin { type?: 'heatmap' + strictlyAligned?: boolean; coordinateSystem?: 'cartesian2d' | 'geo' | 'calendar' @@ -112,7 +113,8 @@ class HeatmapSeriesModel extends SeriesModel { itemStyle: { borderColor: '#212121' } - } + }, + strictlyAligned: false, }; } diff --git a/src/chart/heatmap/HeatmapView.ts b/src/chart/heatmap/HeatmapView.ts index a90a4e4753..a60fc799f7 100644 --- a/src/chart/heatmap/HeatmapView.ts +++ b/src/chart/heatmap/HeatmapView.ts @@ -237,7 +237,12 @@ class HeatmapView extends ChartView { ]); rect = new graphic.Rect({ - shape: { + shape: seriesModel.option.strictlyAligned ? { + x: point[0] - width / 2, + y: point[1] - height / 2, + width: width, + height: height + } : { x: Math.floor(Math.round(point[0]) - width / 2), y: Math.floor(Math.round(point[1]) - height / 2), width: Math.ceil(width), diff --git a/test/heatmap-strictly-aligned.html b/test/heatmap-strictly-aligned.html new file mode 100644 index 0000000000..092e822744 --- /dev/null +++ b/test/heatmap-strictly-aligned.html @@ -0,0 +1,182 @@ + + + + + + + + + + + + + + +
+ + + + \ No newline at end of file