2011-10-26 13 views
31

Tengo un gráfico de columnas simple que actualizo a través de AJAX, y todo funciona bien, excepto que no puedo cambiar el título real del gráfico cuando estoy actualizando los datos.Programmatically change an chart title in highcharts

He intentado lo obvio -

chart.title="new title"; 
//and 
chart.title.text="New title"; 

etc - en vano, y no han tenido éxito la búsqueda de una solución en línea.

Cualquier ayuda será muy apreciada.

Respuesta

66

Puede usar setTitle(titleObj, subTitleObj) para eso.

chart.setTitle({text: "New Title"}); 

ver un ejemplo: jsfiddle

Véase el API Ref.

+0

¡Eso funcionó, gracias! – acullen72

+0

@ user1014950: De nada. –

+2

si está buscando set * subtitle * entonces solo pase null como primer argumento como: 'chart.setTitle (null, {text: 'New title' + i});' –