This is the resultant image I needed
Currently, dimple.js is doing some kind of sorting with the data inputs. I need the color of the Positive values as blue and Negative values as Red. But if I enter a Negative value which is higher than the positive value then the color gets swapped to each other. Dimple js takes the highest value and performs sorting within the plugin.Any ways to prevent sorting
var donut1 = dimple.newSvg("#donutChart1", 220,180);
var data1 = [
{"Response": "18","Type": "Positive"},
{"Response": "32","Type": "Negative"}
];
var myDonutChart1 = new dimple.chart(donut1, data1);
myDonutChart1.setBounds(25, 50, 100, 90);
myDonutChart1.setMargins(35,35,35,0);
myDonutChart1.defaultColors = [
new dimple.color("rgb(128, 177, 211)"),
new dimple.color("rgb(251, 128, 114)")
];
myDonutChart1.addMeasureAxis("p", "Response");
var ring = myDonutChart1.addSeries("Type", dimple.plot.pie);
ring.innerRadius = "50%";
myDonutChart1.addLegend(45,10,250, 100, "left");
myDonutChart1.draw(1300);
ie; If a positive value is 10 and Negative value is 6 it works fine. But if a positive value is 6 and Negative value is 10 then the color gets swapped.
Dimple JS typically sort values based on Value axis defined in a Series, you can override this behavior with
addOrderRule(column name)method.In your case
ring.addOrderRule("Type")is enough to add before draw()