mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 01:13:23 -04:00
This works around the issue described in https://github.com/vega/vega/issues/1146 With this patch, users will be able to set autosize=none, while at the same time rely on Kibana to set width/height. This will only be done when width & height are not set. Testing code: ```hjson { $schema: https://vega.github.io/schema/vega/v3.0.json autosize: none padding: {left: 32, bottom: 24, top: 10, right: 6} background: "#dbb" scales: [ { name: x type: band range: width domain: ["a", "b"] paddingOuter: 0.05 paddingInner: 0.95 } { name: y type: linear range: height domain: [0, 100] } ] data: [ { name: edges values: [ {x1: "a", x2: "b", y1: 50, y2: 50, value: 100} ] transform: [ { type: linkpath orient: horizontal shape: {signal: "'diagonal'"} sourceY: {expr: "scale('y', datum.y1)"} sourceX: {expr: "scale('x', datum.x1) + bandwidth('x')"} targetY: {expr: "scale('y', datum.y2)"} targetX: {expr: "scale('x', datum.x2)"} } { type: formula expr: range('y')[0]-scale('y', datum.value) as: strokeWidth } ] } ] axes: [ {orient: "bottom", scale: "x", zindex: 1} {orient: "left", scale: "y", zindex: 1} ] marks: [ { type: path name: edgeMark from: {data: "edges"} encode: { update: { strokeWidth: {field: "strokeWidth"} path: {field: "path"} } } } ] } ```
This commit is contained in:
parent
0c7b75e9f7
commit
a1dd0704bc
1 changed files with 11 additions and 1 deletions
|
@ -102,7 +102,17 @@ export class VegaParser {
|
|||
* @private
|
||||
*/
|
||||
_calcSizing() {
|
||||
this.useResize = !this.useMap && (this.spec.autosize === 'fit' || this.spec.autosize.type === 'fit');
|
||||
this.useResize = false;
|
||||
if (!this.useMap) {
|
||||
// when useResize is true, vega's canvas size will be set based on the size of the container,
|
||||
// and will be automatically updated on resize events.
|
||||
// We delete width & height if the autosize is set to "fit"
|
||||
// We also set useResize=true in case autosize=none, and width & height are not set
|
||||
const autosize = this.spec.autosize.type || this.spec.autosize;
|
||||
if (autosize === 'fit' || (autosize === 'none' && !this.spec.width && !this.spec.height)) {
|
||||
this.useResize = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Padding is not included in the width/height by default
|
||||
this.paddingWidth = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue