Can I display multiple charts with one call to the render function in ZingChart?

I visited the ZingChart documentation and got acquainted with the rendering methods of several diagrams by calling several rendering functions as follows.

  zingchart.render({
    id:'chartDiv1',
    data:myChart1,
    height:300,
    width:500
  });
  zingchart.render({
    id:'chartDiv2',
    data:myChart2,
    height:300,
    width:500       
  });
  zingchart.render({
    id:'chartDiv3',
    data:myChart3,
    height:300,
    width:500
  });
  zingchart.render({
    id:'dashboardDiv',
    data:myDashboard,
    height:500,
    width:700
  });

But in my code I want to write less code , which should work more for me as it is also directed by my boss .

So my question is Can I display multiple diagrams just by calling one rendering function ? sort of:

zingchart.render({
    id:{'chartDiv1','chartDiv2','chartDiv3','chartDiv4'},
    data:{myChart1,myChart2,myChart3,myChart4},
    height:300,
    width:500
  });

Thanks in advance.

+4
source share
1

, ZingChart.

, javascript.

function renderZingCharts(_id,_data) {
  zingchart.render({
    id: _id,
    data: _data,
    height:300,
    width:500
  });
}

renderZingCharts('chartDiv1', myChart1);
renderZingCharts('chartDiv2', myChart2);
renderZingCharts('chartDiv3', myChart3);
renderZingCharts('chartDiv4', myChart4);

, .

function renderZingCharts(aIds, aData) {

  // do some sanity checks for length of two arrays here ???

  for (var i=0; i < aIds.length; i++) {
    zingchart.render({
      id: aIds[i],
      data: aData[i],
      height:300,
      width:500
    });
  }
}
var ids = ['chartDiv1', 'chartDiv2', 'chartDiv3', 'chartDiv4'];
var configs = [myChart1, myChart2, myChart3, myChart4];
renderZingCharts(ids,configs);
+6

Source: https://habr.com/ru/post/1656214/


All Articles