Skip to content

Chart api simple example

Yuji Takayama edited this page Jul 10, 2013 · 1 revision

This is simple example for how to use Movable Type Chart API.

At first, adding div block to your page that will contain your chart. Make sure it has an ID attribute so you can refer to it in your javascript later.

<div id="graph" style="width: 500px;"></div>

Next, add a script block to your page's

block. then put the following javascript code.

  $(function(){
    var config = {
      data: [
        {
          x: '2013-04',
          y: '123'
        },
        {
          x: '2013-05',
          y: '235'
        },
        {
          x: '2013-06',
          y: '76'
        }
      ]
    }
    var range = {
      dataType: 'general',
      length: 3
    }
    new MT.ChartAPI.Graph(config, range).trigger('APPEND_TO', $('#graph'));
  })

If everything is working correctly, you should see the following chart on your page.

Clone this wiki locally