Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 3 additions & 7 deletions src/plugins/vis_type_vega/public/vega_view/vega_base_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,9 @@ export class VegaBaseView {
const width = Math.max(0, this._$container.width() - this._parser.paddingWidth);
const height =
Math.max(0, this._$container.height() - this._parser.paddingHeight) - heightExtraPadding;
// Somehow the `height` signal in vega becomes zero if the height is set exactly to
// an even number. This is a dirty workaround for this.
// when vega itself is updated again, it should be checked whether this is still
// necessary.
const adjustedHeight = height + 0.00000001;
if (view.width() !== width || view.height() !== adjustedHeight) {
view.width(width).height(adjustedHeight);

if (view.width() !== width || view.height() !== height) {
view.width(width).height(height);
return true;
}
return false;
Expand Down
66 changes: 11 additions & 55 deletions src/plugins/vis_type_vega/public/vega_visualization.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jest.mock('./lib/vega', () => ({
}));

// FLAKY: https://github.com/elastic/kibana/issues/71713
describe.skip('VegaVisualizations', () => {
describe('VegaVisualizations', () => {
let domNode;
let VegaVisualization;
let vis;
Expand All @@ -77,17 +77,17 @@ describe.skip('VegaVisualizations', () => {
mockHeight = jest.spyOn($.prototype, 'height').mockImplementation(() => mockedHeightValue);
};

setKibanaMapFactory((...args) => new KibanaMap(...args));
setInjectedVars({
emsTileLayerId: {},
enableExternalUrls: true,
esShardTimeout: 10000,
});
setData(dataPluginStart);
setSavedObjects(coreStart.savedObjects);
setNotifications(coreStart.notifications);

beforeEach(() => {
setKibanaMapFactory((...args) => new KibanaMap(...args));
setInjectedVars({
emsTileLayerId: {},
enableExternalUrls: true,
esShardTimeout: 10000,
});
setData(dataPluginStart);
setSavedObjects(coreStart.savedObjects);
setNotifications(coreStart.notifications);

vegaVisualizationDependencies = {
core: coreMock.createSetup(),
plugins: {
Expand Down Expand Up @@ -185,49 +185,5 @@ describe.skip('VegaVisualizations', () => {
vegaVis.destroy();
}
});

test('should add a small subpixel value to the height of the canvas to avoid getting it set to 0', async () => {
let vegaVis;
try {
vegaVis = new VegaVisualization(domNode, vis);
const vegaParser = new VegaParser(
`{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"marks": [
{
"type": "text",
"encode": {
"update": {
"text": {
"value": "Test"
},
"align": {"value": "center"},
"baseline": {"value": "middle"},
"xc": {"signal": "width/2"},
"yc": {"signal": "height/2"}
fontSize: {value: "14"}
}
}
}
]
}`,
new SearchAPI({
search: dataPluginStart.search,
uiSettings: coreStart.uiSettings,
injectedMetadata: coreStart.injectedMetadata,
})
);
await vegaParser.parseAsync();

mockedWidthValue = 256;
mockedHeightValue = 256;

await vegaVis.render(vegaParser);
const vegaView = vegaVis._vegaView._view;
expect(vegaView.height()).toBe(250.00000001);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think problem was in that line. I decide to remove that test cause we already have have some snapshots with that adjusted height
image

} finally {
vegaVis.destroy();
}
});
});
});