Reputation: 73
as the topic states i am not quite sure how to change the color of the bar that the user in the CDE Dashboards barchart selects. In the clickaction() method i would like to do something like
function f() {
var mychart = this;
var bar = mychart.getSelection();
bar.color('red');
}
Can someone help me with this? The main problem is that i am not quite sure where i can find the documentation of all objects and methods that i can use in JS. Like is there a way to get access to a specific object in the Dashboard? Like:
var chartXY = Dashboards.getObject('Chart XY');
I hope anyone can provide some helpful links or some documentation of all methods that can be used in JS. Thanks in advance.
Upvotes: 0
Views: 3602
Reputation: 73
Ok i managed it by myself and want to share it with you guys. I did it like this, in the PreExecution i added:
function changeBars(){
var cccOptions = this.chartDefinition;
// For changing extension points, a little more work is required:
var eps = Dashboards.propertiesArrayToObject(cccOptions.extensionPoints);
// add extension points:
eps.bar_fillStyle = function getColor(){
var val = this.scene.vars.value.value;
var atom = this.scene.atoms;
var category = atom.category.label;
if(category == selection_param){
return "red";
}else{
return "blue";
}
};
// Serialize back eps into cccOptions
cccOptions.extensionPoints = Dashboards.objectToPropertiesArray(eps);
}
You need to listen for the selected_param which will be set every time a bar of the particular chart is selected. I hope this is helpful. Also in case there is a more elegant way please let me know.
Upvotes: 2