Estoy usando los últimos echarts e intento poner un rectángulo en el lienzo usando la opción gráfica . Podemos establecer el ancho y la altura del type: 'rect' usando Shape.width y Shape.height de acuerdo con esta documentación.
Lo que quiero hacer es que quiero cambiar ese ancho y alto del rectángulo.
Aquí está el código de opción de muestra que estoy tratando de implementar actualmente. Puede usarlo reemplazándoloaquí . La función setWidth() puede cambiar el valor de la variable de ancho, pero Shape.width no volverá a llamar a la función getWidth() . No habrá un nuevo renderizado sucediendo.
let width = 100; function getWidth() { return width; } function setWidth(value) { width = value; } option = { graphic: { elements: [ { type: 'rect', draggable: true, shape: { x: 0, y: 0, width: getWidth(), height: 100 }, style: { fill: 'red' }, onclick: function(e) { setWidth(400) } } ], grid: { left: '3%', right: '4%', bottom: '3%', containLabel: true } } };