pentaho CDE conditional formatting of bubble chart

2019-09-09 09:14发布

I have used CCC Heat Grid in CDE to create a bubble chart with bubbles of different colors. My data set has only 6 values: (1, 1.1, 2, 2.1, 3, 3.1). I have sizeRole property to "value" so that the size of the bubble varies based on the magnitude of these six values. Alternative, I could have set colorRole property to "value". I have set three colors: green (1), yellow (2) and red (3).

Now, what I want to have 1 as green, 2 as yellow and 3 as red; and biggest constant size for 1.1, 2.1 and 3.1. The values 1.1, 2.1 and 3.1 represent alarms in my data set, so I want them to be of biggest size bubble or some other differentiating visual element.

I tried the following in pre-execution but no luck

function changeBubbles(){
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_shape = function getShape(){
var val = this.scene.vars.value.value;

if(val == 1.1 || val == 2.1 || val == 3.1){
return 'cross';
} 
else {}
};

// Serialize back eps into cccOptions
cccOptions.extensionPoints = Dashboards.objectToPropertiesArray(eps);
}

How can we achieve this?

标签: pentaho-cde
1条回答
霸刀☆藐视天下
2楼-- · 2019-09-09 09:45

I hope the answer is still relevant, given that this is a late response.

To use bubbles you should have useShapes: true. You can set a different constant shape by using the shape option. For example, shape: "cross".

To have the bubble size be constant, you should set the "sizeRole" to null: sizeRole: null. Bubbles will take all of the available "cell" size.

Then, the "value" column should be picked up by the "colorRole", but to be explicit, specify: colorRole: "value".

By default, because the color role will be bound to a continuous dimension ("value"), the color scale will be continuous as well.

To make it a discrete scale, change the "value" dimension to be discrete:

dimensions: {
    "value": {isDiscrete: true}
}

Finally, to ensure that the colors are mapped to the desired values, specify the "colorMap" option:

colorMap: {
    "1": "green",
    "2": "yellow",
    "3": "red"
}

That's it. I hope this just works :-)

查看更多
登录 后发表回答