Skip to content

Commit 2d9cb4b

Browse files
authored
BarGauge: throw W2104 if there is no place for render legend (T1307508) (#31115)
1 parent 98a5516 commit 2d9cb4b

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

packages/devextreme/js/__internal/viz/gauges/bar_gauge.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,9 @@ export const dxBarGauge = BaseGauge.inherit({
475475
const that = this;
476476
const options = that._options.silent();
477477

478+
const legendOptions = that._themeManager.theme('legend');
479+
legendOptions._incidentOccurred = that._incidentOccurred;
480+
478481
that._palette = that._themeManager.createPalette(options.palette, {
479482
useHighlight: true,
480483
extensionMode: options.paletteExtensionMode,

packages/devextreme/js/__internal/viz/utils.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,7 @@ export let prepareSegmentRectPoints = function (left, top, width, height, border
8080
return { points, pathType: visiblyOpt === 15 ? 'area' : 'line' };
8181
};
8282

83-
export {
84-
refreshPaths,
85-
};
86-
87-
export const areCanvasesDifferent = function (canvas1, canvas2) {
83+
const areCanvasesDifferent = function (canvas1, canvas2) {
8884
const sizeChangingThreshold = 1;
8985

9086
const sizeLessThreshold = ['width', 'height']
@@ -95,14 +91,20 @@ export const areCanvasesDifferent = function (canvas1, canvas2) {
9591
return !(sizeLessThreshold && canvasCoordsIsEqual);
9692
};
9793

98-
export const floorCanvasDimensions = function (canvas) {
94+
const floorCanvasDimensions = function (canvas) {
9995
return {
10096
...canvas,
10197
height: floor(canvas.height),
10298
width: floor(canvas.width),
10399
};
104100
};
105101

102+
export {
103+
areCanvasesDifferent,
104+
floorCanvasDimensions,
105+
refreshPaths,
106+
};
107+
106108
/// #DEBUG
107109
exports._test_prepareSegmentRectPoints = function () {
108110
// @ts-expect-error

packages/devextreme/testing/tests/DevExpress.viz.gauges/barGauge_new.tests.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,15 @@ QUnit.test('Legend update should call trigger core content rerender', function(a
345345
assert.strictEqual(gauge.renderCount, initialRenderCount + 1);
346346
});
347347

348+
QUnit.test('gauge legend should have the same reference to _incidentOccurred as gauge itself (T1307508)', function(assert) {
349+
const gauge = this.createGauge({});
350+
351+
const gaugeIncidentOccurred = gauge._incidentOccurred;
352+
const legendIncidentOccurred = gauge._themeManager.theme('legend')._incidentOccurred;
353+
354+
assert.strictEqual(gaugeIncidentOccurred, legendIncidentOccurred, 'functions are the same');
355+
});
356+
348357
QUnit.module('Center Template', environment);
349358

350359
QUnit.test('Should create group for center template on widget creating', function(assert) {

0 commit comments

Comments
 (0)