我正在使用dojox.charting.widget.Chart2D,并且正在尝试从dojo.data.ItemFileReadStore检索数据。我可以检索数据,一切都可以正常工作和显示,除了我似乎找不到一种方法来显示项目上的自定义标签。我的HTML代码片段是:
<div dojoType="dojo.data.ItemFileReadStore" jsId="chartDataStore"
url="json/archiveinfo.json.php"></div>
<div dojoType="dojox.charting.widget.Chart2D" id="chartTest"
theme="dojox.charting.themes.PlotKit.blue" style="width: 300px; height: 300px;">
<div class="plot" name="default" type="Pie" fontColor="black" htmlLabels="false"
radius="100"></div>
<div class="series" name="Series A" store="chartDataStore" field="y"
label="text" valueFn="Number(x)"></div>
<div class="action" type="Tooltip"></div>
<div class="action" type="MoveSlice"></div>
</div>我从ItemFileReadStore得到的JSON是:
{"identifier":"id","labelAttribute":"text","items":
[
{"id":1,"y":55,"text":"Free"},
{"id":2,"y":45,"text":"Used"}
]
}我尝试在该系列中设置label属性,并在JSON中设置了labelAttribute。我还尝试了在JSON中只使用label,它也不起作用。当我在array中以JSON的形式提供数据时,或者在本系列中直接提供data时,我就可以使用标签了。不过,我真的想通过DataStore提供数据,让它变得更加灵活。
发布于 2010-01-11 15:24:58
方法是稍微修改一下JSON并在HTML中更新相应的属性。
JSON:
{
"items": [
{"id":1, "slice": {"y":55,"text":"Free"}},
{"id":2, "slice": {"y":45,"text":"Used"}}
]
}唯一有意义的更改是为了简单起见,将特定于饼的数据分离到子对象(slice)中。
HTML (只修改与商店相关的行):
<div class="series" name="Series A"
store="chartDataStore" field="slice"></div>让我知道进展如何。
发布于 2012-02-08 02:27:35
我不得不面对与自定义标签类似的问题,尽管我使用编程方式在div上创建图表……希望这能帮助某些人……
var mytooltip = new dojox.charting.action2d.Tooltip(mychart,"default",
{text: function(e) {
var tooltiptext = <construct ur custom label here>
return tooltiptext;
}
}); mychart是我用来创建图表小部件的变量。
https://stackoverflow.com/questions/1977170
复制相似问题