如何在dojox列图表中显示高于柱线的值 [英] How to show values above bars in a dojox columns chart

查看:148
本文介绍了如何在dojox列图表中显示高于柱线的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在dojox列类型图表中显示实际栏上方每个栏的y值?这里是我的代码(我从 http://glenurban.me.uk /A55D03/Blog.nsf/dx/DojoChart.htm ):

Is there any way to show the y-value of every bar above the actual bar in a dojox columns-type chart? Here's my code (which I got from http://glenurban.me.uk/A55D03/Blog.nsf/dx/DojoChart.htm):

<script type="text/javascript">
dojo.require("dojox.charting.Chart2D");

var series1 = [ 3, 2, 5, 3, 6, 4]; 
var xlabels = [ 
    {value : 1, text : "a"}, 
    {value : 2, text : "b"}, 
    {value : 3, text : "c"}, 
    {value : 4, text : "d"}, 
    {value : 5, text : "e"}, 
    {value : 6, text : "f"}, 
    {value : 7, text : "g"}];

var chart1;
makeCharts = function() {
    chart1 = new dojox.charting.Chart2D("simplechart");
    chart1.addPlot("default", {
        type : "Columns",
        gap : 2
    });
    chart1.addAxis("x", {
        labels : xlabels
    });
    chart1.addAxis("y", {
        vertical : true,
        min : 0
    });
    chart1.addSeries("Series1", series1);
    chart1.render();
};

dojo.addOnLoad(makeCharts);
</script>


推荐答案

不幸的是,未包含在Dojo的更高版本中:请参见机票,此 ticket (从此邮寄名单。)

Unfortunately, it looks like this is a feature that still hasn't been included into the later versions of Dojo: see ticket, and this ticket (found from this mailing list.)

我试过检查是否有办法使用Dojo GFX从您的数据系列中获取值...,然后将其覆盖到图表上。但是,这样做的标签将是kludgy (这一切取决于如果Dojo GFX的表面允许已经创建的SVG图表对象上的表面覆盖)。

I've tried checking to see if there is a way to use Dojo GFX to get the values from your series of data... and then overlay that on to the chart. But, doing labels that way is going to be kludgy (and this all depends on if Dojo GFX's surface allows for a surface overlay on a SVG chart object already created.)

总是有选项将这个功能添加到Dojo Chart2D库本身。但是每当你这样做,除非你能够使用主Dojo Chart2D分支更改补丁,你需要注意不要在以后用新版本的Chart2D覆盖自定义的库。

There's always the option to add this functionality in to the Dojo Chart2D library itself. But whenever you do that, unless you are able to get your patches changed with the main Dojo Chart2D branch, you'll want to be careful not to overwrite your custom-made library with a newer version of Chart2D in the future.

但是,如果你没有因为这个特殊需要而坚持使用Dojo,那么你是否考虑过使用 jQuery ?有很多不同的图表/图表库,这些天:

However, if you aren't stuck to Dojo for this particular need, have you considered using jQuery? There are many different chart/graph libraries out there, these days:


  1. Highcharts 示例

  2. Flot 示例

  3. Tuftegraph examples

  1. Highcharts (examples)
  2. Flot (examples)
  3. Tuftegraph (examples)

此外, Google图表工具非常不错,如果jQuery不是你的东西。

Also, Google Chart Tools is pretty nice, if jQuery isn't your thing.

a href =http://thejit.org/demos/ =nofollow> JavaScript InfoVis Toolkit 也很棒。

Or... JavaScript InfoVis Toolkit is great, as well.

这篇关于如何在dojox列图表中显示高于柱线的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆