({
doInit : function(component, event, helper){
if ([Link]("[Link]") == true){
[Link]("[Link]", "pure-u-1-2");
} else {
[Link]("[Link]", "pure-u-1-1");
}
},
////
// Load data from Apex Data Provider and draw chart.
createChart : function(component, event, helper){
var action = [Link]("[Link]");
[Link]({"dataProviderName":[Link]("[Link]")});
[Link](this, function(a){
var response = [Link]();
if (response == null || response == "" || response == "[]" || response
== "{}"){
[Link]("[Link]", true);
return;
} else {
[Link]("[Link]", false);
}
[Link](component, [Link](response), {});
});
$[Link](action);
},
////
// updateChart is triggered by ChartDateUpdate event. If event provide chart
data, updateChart draws chart with it. Otherwise, do the same as createChart.
updateChart : function(component, event, helper){
var chartData = [Link]("chartData");
var componentName = [Link]("componentName");
if (chartData == null || componentName == null){
var action = [Link]("[Link]");
[Link]({"dataProviderName":[Link]("[Link]")});
[Link](this, function(a){
var response = [Link]();
if (response == null || response == "" || response == "[]" ||
response == "{}"){
[Link]("[Link]", true);
return;
} else {
[Link]("[Link]", false);
}
[Link](component, [Link](response), {});
});
$[Link](action);
} else {
[Link](component, chartData, {});
}
},
////
// changeChartType is triggered when ChartTypeChange event is fired.
changeChartType : function(component, event, helper){
// Retrieve target component id and this component's global id.
// If this component instance is not target, exit.
var globalId = [Link]();
if (globalId != [Link]("componentId")){
return;
}
// Retrieve chart instance and destroy to clean the canvas.
var chart = [Link]("[Link]");
[Link]();
// Draw new chart with new chart type and existing chart data & option.
var ctx = [Link](globalId + "_chart").getContext("2d");
chart = new Chart(ctx)[[Link]("chartType")]
([Link]("[Link]"), [Link]("[Link]"));
// Set new chart instance to component property.
[Link]("[Link]", chart);
[Link]("[Link]", [Link]("chartType"));
}
})