Skip to content

Commit a79f1dc

Browse files
committed
fix(histogram): 直方图 histogram 修复不能关闭 legend 的问题
1 parent dd090c2 commit a79f1dc

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

__tests__/unit/plots/histogram/index-spec.ts

+19
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,25 @@ describe('histogram', () => {
148148
histogram.destroy();
149149
});
150150

151+
it('直方图 关闭 legend', () => {
152+
const histogram = new Histogram(createDiv('legend * true'), {
153+
width: 400,
154+
height: 300,
155+
appendPadding: 10,
156+
data: histogramStackData,
157+
binField: 'value',
158+
binWidth: 4,
159+
legend: false,
160+
});
161+
162+
histogram.render();
163+
164+
//@ts-ignore
165+
expect(histogram.chart.getController('legend').components.length).toEqual(0);
166+
167+
histogram.destroy();
168+
});
169+
151170
it('stackField with color', () => {
152171
const colors = ['red', 'blue'];
153172
const histogram = new Histogram(createDiv(), {

src/plots/histogram/adaptor.ts

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ function geometry(params: Params<HistogramOptions>): Params<HistogramOptions> {
3939
// 图例
4040
if (legend && stackField) {
4141
chart.legend(stackField, legend);
42+
} else {
43+
chart.legend(false);
4244
}
4345

4446
return params;

0 commit comments

Comments
 (0)