Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

208
Views
Cómo cambiar el ancho y la altura del gráfico 'rect' mediante programación en Echarts (implementando el evento onClick o haciéndolo redimensionable arrastrándolo)

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.

  1. haciendo clic en él (al implementar el evento onClick )
  2. arrastrando como en css la propiedad 'cambiar tamaño' a un div. ¿Es esto posible en echarts?

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 } } };
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Las opciones de los gráficos electrónicos no suelen ser dinámicas. Lo que significa que si cambia alguna opción, deberá llamar a yourChartName.setOption(option) ( doc ).

 function setWidth(value) { option.graphic.elements[0].shape.width=value; myChart.setOption(option); }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!