Im having trouble setting color to chart and pie chart elements. While using sample provided:
ConditionalColorSample . While it seems to semi work with hex color code and rgb, rgba alpha channel gets completely ignored resulting in incorrect color painting. Code snippet below.
JavaScriptSetCustomColor: function (s, e) {
var conditionalColorsArray = dashboardViewer1.cpConditionalColors;
var config = $.grep(conditionalColorsArray, function(item) {
return item.DasboardItemName === e.ItemName;
});
if (config.length === 0) return;
var measureDescriptor = e.GetMeasures()[0];
var configEntry = $.grep(config[0].TestEntries, function (entry) {
return entry.Measure.ID === measureDescriptor.Id;
});
if (configEntry.length === 0) return;
var data = dashboardViewer1.GetItemData(e.ItemName);
var currentElement = e.GetTargetElement();
var effectiveCondition = configEntry[0].TestDefaultCondition;
if (effectiveCondition == null) return;
var sliceData = data.GetSlice(currentElement);
var measureValue = sliceData.GetMeasureValue(measureDescriptor.Id).GetValue();
if (measureValue == null) return;
var nTarget = null;
if (effectiveCondition.DynamicTarget != null) {
var sliceMeasures = sliceData.GetMeasures();
var targetMeasureDescriptor = $.grep(sliceMeasures, function(measure) {
return measure.Id === effectiveCondition.DynamicTarget.Measure.ID;
});
if (targetMeasureDescriptor == null) return;
var targetValue = sliceData.GetMeasureValue(targetMeasureDescriptor[0].Id).GetValue();
nTarget = targetValue;
}
else if (effectiveCondition.StaticTarget != null) {
nTarget = effectiveCondition.StaticTarget.Value;
}
if (nTarget == null) return;
if (measureValue > nTarget) {
e.SetColor(effectiveCondition.RGBAAboveColor);
}
if (measureValue < nTarget) {
e.SetColor(effectiveCondition.RGBABelowColor);
}
if (measureValue === nTarget) {
e.SetColor(effectiveCondition.RGBAEqualsColor);
}
},
The colors in effective conditions are in "rgba(r,g,b,a)" format.
Hi,
We've reproduced this behavior and passed this ticket to our developers. As an immediate workaround, please set color in rgb format.