score:0

create a new canvas object and position it under the actual chart. this new chart has the split data values. make sure that the datapoints in your original chart that are split have a transparent background so that the underlying splits show through.


preview

enter image description here


html

<div class="splitcontainer">
  <canvas id="canvas" height="300" width="800"></canvas>
  <canvas class="canvassplit" id="canvas2" height="300" width="800"></canvas>
</div>

css

.splitcontainer {
  position: relative;
}

.canvassplit {
  z-index: -1;
  position: absolute;
  top: 0;
  left: 0;
}

script

var datapichart2 = [
  {
    value: 200,
    color:"rgba(247, 70, 74, 0.6)",
    label: "php1"
  },
  {
    value: 150,
    color:"rgba(247, 70, 74, 0.2)",
    label: "php2"
  },
  // values that are not split remain as is
  {
    value: 100,
    color: "#46bfbd",
    label: "javascript"
  },
  {
    value: 500,
    color: "#fdb45c",
    label: "html"
  }
];

new chart(document.getelementbyid('canvas2').getcontext("2d")).pie(datapichart2, {
  segmentshowstroke: false
});

var datapichart = [
  {
    value: 350,
    // transparent show the split shows through
    color:"rgba(247, 70, 74, 0.2)",
    highlight: "rgba(247, 70, 74, 0.7)",
    label: "php"
  },

fiddle - http://jsfiddle.net/ww8qpdvw/


Related Query

More Query from same tag