java - 使用 jQplot 实现图表

标签 java javascript jquery jqplot

我的需要是实现下图

enter image description here

我知道 stacked chart ,但这里有轴点标签(在我的需要中没有任何轴点标签),这是来自 Y 轴。

我很困惑如何实现它。

你能帮我一下吗?任何链接也会有帮助。

<小时/>

更新:

我正在尝试代码片段

<script type="text/javascript" language="javascript">

  $(document).ready(function(){
      var line1 = [14];
      var line2 = [77];
      var plot4 = $.jqplot('test2', [line1, line2], {
          title: '1 Mobility Test Graph',
          animate: !$.jqplot.use_excanvas,
          stackSeries: true, 
          seriesDefaults: {
              renderer: $.jqplot.BarRenderer,
              rendererOptions:{barPadding : 0, barMargin : 5, barDirection: 'horizontal'}, 
              pointLabels:{location : 'e', edgeTolerance : 0, hideZeros: true, show : true},
              shadowAngle : 135,
              lineWidth : 0,
              showLine: true
          },
          axesDefaults : {
                show : false,
                tickOptions : {
                    show : false
                }
            },
          axes: {
              yaxis:{renderer:$.jqplot.CategoryAxisRenderer}
          },
          grid:{
                borderWidth:0, 
                shadow:false
            },
          legend: {
                renderer: $.jqplot.EnhancedLegendRenderer,
                show:true,
                rendererOptions:{
                    numberRows:1,
                    numberColumns: 3,
                    disableIEFading: false
                },
                location: 'n',
                placement : 'outsideGrid',
                marginTop: '5px',
                showSwatch:false
          }
      });
      $(".jqplot-xaxis-tick").hide();
      $(".jqplot-yaxis-tick").hide();
    });
</script>

但这并没有给我任何输出。当我删除 barDirection: 'horizo​​ntal' 时,它工作正常。请帮助我,出了什么问题......

这里我得到了jsfiddle ,但它适用于两张图……我怎样才能制作一张图。

最佳答案

你在寻找类似 this 的东西吗? ?那里有一个堆叠的单杠。 根据examples in doc对于水平条形图,您必须为图表提供一个系列数组,其中每个系列的值都是两个值数组 ([x,y]),其中 x 是值,y 是系列 ID。

或者另一种选择是为图表提供一个由单值数组组成的数组,如 shown here .

关于java - 使用 jQplot 实现图表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12898047/

相关文章:

java - Spring JSON 转换器。如何绑定(bind)不同类型

java - bouncy caSTLe pgp - PartialInputStream 中的流过早结束

Java Array - 计算周围数字的平均值

javascript - 如何从客户端将参数添加到 HttpContext.Request.Form 中

javascript - 如何使用 webpack 将脚本文件从 src 复制到 dist

java - 随机 - 当 'int y' % 2 == 0 && 'int y' != 2 的幂时,nextInt(int y) 无法连续给我 18 个偶数整数

javascript - 通过 AJAX 更新 Rails 模型?

javascript - 如何正确设置helmet.js 以解决CSP 问题?

javascript - 延迟 jQuery 脉动与计时器相结合

java - 关于Struts 2框架中的HTML标签