Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 3rd, 2012  |  syntax: None  |  size: 1.21 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. var myDataValues = [
  2.     {category:"5/1/2010", values:2000},
  3.     {category:"5/2/2010", values:50},
  4.     {category:"5/3/2010", values:400},
  5.     {category:"5/4/2010", values:200},
  6.     {category:"5/5/2010", values:5000}
  7. ];
  8. var mychart = new Y.Chart({
  9.         dataProvider: myDataValues,
  10.         render: "#mychart",
  11.         horizontalGridlines: true,
  12.         verticalGridlines: true
  13.     });
  14.     var mygraphic = mychart.get("graph").get("gridlines").get("graphic"),
  15.         w = mygraphic.get("width"),
  16.         h = mygraphic.get("height"),
  17.         //set ycoordinate to 85%
  18.         ycoord = Math.round(h - (h * .85)),
  19.         myshape,
  20.         //store current state of Graphic's autoDraw attribute
  21.         autoDraw = mygraphic.get("autoDraw");
  22.     //set graphic's autoDraw attribute to true    
  23.     mygraphic.set("autoDraw", true);
  24.     //create and style path shape
  25.     myshape = mygraphic.addShape({
  26.         type: "path",
  27.         stroke: {
  28.             color: "#f00",
  29.             weight: 3,
  30.         }
  31.     });
  32.     //draw the line at 85%
  33.     myshape.clear();
  34.     myshape.moveTo(0, ycoord);
  35.     myshape.lineTo(w, ycoord);
  36.     myshape.end();
  37.     //set the graphic's autoDraw attribute to its previous state
  38.     mygraphic.set("autoDraw", autoDraw);
  39. });