Skip to content

Instantly share code, notes, and snippets.

@tripp
Created May 31, 2011 17:32
Show Gist options
  • Save tripp/1000926 to your computer and use it in GitHub Desktop.
Save tripp/1000926 to your computer and use it in GitHub Desktop.
Chart with DataSource
var pieGraph = new Y.Chart({
render:"#mychart",
categoryKey:"Domain",
seriesKeys:["Hit"],
dataProvider:[],
type:"pie",
seriesCollection:[
{
categoryKey:"Domain",
valueKey:"Hit"
}
]
});
var myDataValues = new Y.DataSource.IO({source:"getdata.php"}),
myCallBack = {
success: function(e) {
pieGraph.set("dataProvider", e.response.results);
},
failure: function(e) {
//handle failure
}
};
myDataValues.plug({fn: Y.Plugin.DataSourceJSONSchema, cfg: {
schema: {
resultListLocator: "results",
resultFields: ["Domain", {key:"Hit", parser:"number"}]
}
}});
myDataValues.sendRequest({
request:"?json",
callback: myCallBack
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment