lundi 27 juin 2016

How to pass an array from php to chart.js data?

I have this array $data_dispensed, when I echo json_encode($dataary) it, I get

{ "aaa": 11, "bbb": 8, "ccc": 7, "ddd": 7, "eee": 7, "fff": 6, "ggg": 6, "hhh": 6, "iii": 6, "jjj": 35 }

and my chart data as below,

var echartDonut = echarts.init(document.getElementById('echart_donut'), theme);

  echartDonut.setOption({

        emphasis: {
          label: {
            show: true,
            position: 'center',
            textStyle: {
              fontSize: '14',
              fontWeight: 'normal'
            }
          }
        }
      },  legend: {
      x: 'center',
      y: 'bottom',
      data: ['Direct Access', 'E-mail Marketing', 'Union Ad', 'Video Ads', 'Search Engine','AAA','BBB','CCC']  //and replace the data too ???????????
    },
     data: ////how to replace it to php array ?
      {
        value: 10,
        name: 'Direct Access'
      }, {
        value: 20,
        name: 'E-mail Marketing'
      }, {
        value: 30,
        name: 'Union Ad'
      }, {
        value: 40,
        name: 'Video Ads'
      }, {
        value: 50,
        name: 'Search Engine'
      },{
    value:60,
    name: 'AAA'

   },{
    value:70,
    name: 'BBB'  
      },{
    value:80,
     name: 'CCC'
              }
      ]
    }]
  });

I want to pass array from php to data ? Hot to do it ? How to replace the data to php array ?? Any help will be appreciated! thanks!

Aucun commentaire:

Enregistrer un commentaire