gsp.bi.stage.requireLibraries(function(gvc,dc,d3,cf){gsp.bi.stage.findStage(null,function(stage){varstageModel=stage.stageModel();varelement=document.createElement("div");vardcWidget=dc.someWidget(element);/* create custom DC.js widget code here */// create wrapper for dcWidgetvarcustomWidget=gvc.chart.base(dcWidget);// configure grouping with key propertycustomWidget.group(function(d){returnd.key});// IMPORTANT: all widgets must provide "colors" method even if it does not do something.// dataTable.colors = function() {}; // add it if DC widget does not provide one// add the widget to the stage and add it to DOM in a callbackgsp.bi.stage.addWidget({descriptor:{chartM:{id:"my-custom-widget",name:"My custom widget",title:"Custom Widget",key:stageModel.fields[0].id,// modifyvalues:[stageModel.values[0].id]// modify},chart:dataTable}},function(success){varcontainer=document.querySelector(".my-custom-widget").querySelector(".widget-chart");container.innerHTML="";container.classList.add("my-custom-widget-interior");container.appendChild(element);},function(error){console.error(error);});});});
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.