[ 2 posts ]

Adityo Deshmukh

  • Username: adie
  • Joined: Thu Jul 05, 2012 9:26 pm
  • Posts: 1
  • IRC: adityo
  • Offline
  • Profile
Tags:

Can we create a donut chart using yui charts

Post Posted: Thu Jul 05, 2012 9:35 pm
+0-
I was just wondering , is it possible to create donut charts in YUI by modifying the pie chart, i looked at the API docs but cannot find any way of creating them

Tripp Bridges

YUI Developer

  • Username: tripp
  • Joined: Wed Jan 07, 2009 1:54 pm
  • Posts: 440
  • GitHub: tripp
  • Gists: tripp
  • YUI Developer
  • Offline
  • Profile

Re: Can we create a donut chart using yui charts

Post Posted: Fri Jul 06, 2012 10:22 am
+0-
Currently, there is no DonutSeries. Please file ticket and I will add one. Since a donut is a pie with a different drawing algorithm, you could alter or extend the pie to create a donut. If you wanted to create a donut, you could look into altering
PieChart and PieSeries. You would also need to create a custom shape for the donut "slices".

If you wanted to do something quick and dirty, you could be place a circle over the center of a pie with the same background color as your container. Below is a method demonstrating this approach. You would pass it the same config object you would normally pass to the Chart object.

Code:
function getDonutChart(cfg)
{
    var pieGraph = new Y.Chart(cfg),
        graphic = pieGraph.get("graph").get("graphic"),
        w = graphic.get("width"),
        h = graphic.get("height"),
        autoDraw = graphic.get("autoDraw"),
        hole;
    graphic.set("autoDraw", true);   
    hole = graphic.addShape({
        type: "circle",
        radius: w/4,
        x: w/4,
        y: h/4,
        fill: {
            color: "#fff"
        },
        stroke:{
           weight: 0
        }
    });
    graphic.set("autoDraw", autoDraw);
    return pieGraph;
}


Thanks,
Tripp
  [ 2 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum