i'm new javascript , dojo please bear me. i'm trying create pie chart using dataseries object, this:
var skillstore = new dojo.data.itemfilereadstore({ url: "/data/skillhead.json" }); function formatpiechartdata(store, item) { var tooltips = { available: "available agents", onacd: "agents on acd calls", inacw: "agents in acw", inaux: "agents in aux", aginring: "agents ringing phones", other: "agents otherwise occupied", }; var ivalue = store.getvalue(item, "value"); var legend = store.getvalue(item, "legend"); var tooltip = tooltips[store.getvalue(item, "field")]; var o = { y: ivalue, legend: legend, tooltip: tooltip } return o; } /* how data looks after massaging var chartdata = [ { y: 10, legend: "avail", tooltip: "available agents" }, { y: 20, legend: "onacd", tooltip: "agents on acd calls" }, { y: 30, legend: "inacw", tooltip: "agents in acw" }, { y: 40, legend: "inaux", tooltip: "agents in aux" }, { y: 50, legend: "inring", tooltip: "agents ringing phones" }, { y: 60, legend: "other", tooltip: "agents otherwise occupied" } ]; */ var series = new dojox.charting.dataseries(skillstore, { query: { field: new regexp("inacw|inaux|aginring|other|" + "available|onacd") } }, formatpiechartdata); dojo.addonload( function() { chart = new dojox.charting.chart("chartnode"); chart.settheme(dojox.charting.themes.primarycolors); chart.addplot("default", { type: "pie", radius: 85, labels: false, ticks: false, markers: false }); chart.addseries("default", series); var highlight = new dojox.charting.action2d.highlight(chart, "default"); var tip = new dojox.charting.action2d.tooltip(chart, "default"); grid.startup(); chart.render(); legend = new dojox.charting.widget.legend({ chart: chart, horizontal: false, style: "font-size: 11px;", }, "chartlegend"); legend.startup(); settimeout(function(){ legend.refresh() }, 1000); });
it works fine, except 1 thing: don't fixed timeout. have refresh legend after data loaded, otherwise not displayed; don't know event attach in order refresh legend right after data fetched. see dataseries class has onfetcherror event no onfetchsuccess event. how know data loaded successfully?
i know late, i'm posting anyway in case has same issue. took through dataseries.js , have undocumented hook using. can't promise stay same throughout api updates, looks like:
dojo.connect(dataseries, "_onfetchcomplete", myobj, "myfunction");
see http://dojotoolkit.org/reference-guide/dojo/connect.html
Comments
Post a Comment