Search code examples
extjslabelchartstitleextjs4

Is it possible to add title to charts?


I want to add a title to a chart, like in the gauge example or a pie chart. I want to display a title under or on top of the chart. Is this possible? I've been looking and can't find anything about this. if so , any tip to share? it would be something like this  gauge with titles

EDIT: i found there is a property to create text sprites for the title or any labels at the Ex.draw package. but i couldnt understand how to use it..

anybdy here have done the same?


Solution

  • Since Ext.chart.Chart is an Ext.draw.Component, you can add sprites as items of it. Try to use this:

    Ext.create('Ext.chart.Chart', {
       default chart settings here
    
       ...
    
       items: [{
          type  : 'text',
          text  : 'Simple Title',
          font  : '14px Arial',
          width : 100,
          height: 30,
          x : 50, //the sprite x position
          y : 10  //the sprite y position
       }]
    })