Dojo 图表:如何将标签从数据存储添加到我的 Axis?
我仍然是 dojo 和 javascript 的新手,所以这可能是微不足道的。
我创建了一个“dojox.charting.Chart2D”图表。
我从数据存储 (ItemFileReadStore) 获取数据,并可以在我的 DataSeries 中成功显示它们。 我还可以创建 xay 轴,但仅包含简单的数字。 我需要的是将商店中一个字段的文本值添加到我的 x 轴。 我发现这可以通过“labelFunc: function (n) {}”来完成,但我根本无法让它从我的商店读取数据。
我的商店数据如下所示:
{ identifier: "UniqueId" , items: [
{"UniqueId":1, "VisitDate":"2012-02-21T00:00:00", "VisitsTotal":407, "Visits10":71, "Visits15":6},
{"UniqueId":2, "VisitDate":"2012-02-20T00:00:00", "VisitsTotal":508, "Visits10":80, "Visits15":10},
...
我的代码如下:
var store = new dojo.data.ItemFileReadStore({ url: './../Data/MyJSONData.aspx' });
chart1 = new dojox.charting.Chart2D("simplechart1");
chart1.addAxis("x", {fixUpper: "major",fixLower: "minor",title: 'Datum',
labelFunc: function (n) {
// HOW DO I GET THE VALUES 'VisitDate' FROM MY STORE ???
}});
chart1.addSeries('VisitsTotal',
new dojox.charting.DataSeries(store, { query: { Visits10: "*"} }, "Visits10"),
{ stroke: 'red', fill: 'pink' }
);
chart1.addSeries('Visits10',
new dojox.charting.DataSeries(store, { query: { Visits10: "*"} }, "Visits10"),
{ stroke: 'red', fill: 'pink' }
);
...
我已经尝试过任何组合,但我确实缺少一些基础知识,例如如何从商店读取以及如何将我自己的文本值(标签)设置到我的 X 轴。
先感谢您。
I am still a newbie in dojo and javascript so this may be trivial.
I have created a "dojox.charting.Chart2D"-chart.
I get the data from a datastore (ItemFileReadStore) and can successfully display them in my DataSeries.
I can also create my x a y Axis but the only contain simple numbers.
What i need is to add to my x-Axis the text values from one field in my store.
I found that this could be done with "labelFunc: function (n) {}" but i simply can't get it to read the data from my store.
My store data looks like this:
{ identifier: "UniqueId" , items: [
{"UniqueId":1, "VisitDate":"2012-02-21T00:00:00", "VisitsTotal":407, "Visits10":71, "Visits15":6},
{"UniqueId":2, "VisitDate":"2012-02-20T00:00:00", "VisitsTotal":508, "Visits10":80, "Visits15":10},
...
My code is like this:
var store = new dojo.data.ItemFileReadStore({ url: './../Data/MyJSONData.aspx' });
chart1 = new dojox.charting.Chart2D("simplechart1");
chart1.addAxis("x", {fixUpper: "major",fixLower: "minor",title: 'Datum',
labelFunc: function (n) {
// HOW DO I GET THE VALUES 'VisitDate' FROM MY STORE ???
}});
chart1.addSeries('VisitsTotal',
new dojox.charting.DataSeries(store, { query: { Visits10: "*"} }, "Visits10"),
{ stroke: 'red', fill: 'pink' }
);
chart1.addSeries('Visits10',
new dojox.charting.DataSeries(store, { query: { Visits10: "*"} }, "Visits10"),
{ stroke: 'red', fill: 'pink' }
);
...
I already tried any combination but i really am missing some basics, on how to read from the store and also how to set my own text values (labels) to my X-Axis.
Thank you in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
向 X 轴添加(标签)。
或参见我的 jsfiddle。
< strong>从商店读取数据
查看更多信息Dojo Livedoc 或 stackoverflow
Add (labels) to X-Axis.
Or see in My jsfiddle.
Read data from the store
See more at Dojo Livedoc or stackoverflow