2015-09-27 98 views
1

我是新来的海军报。我有这样的条形图: enter image description here海军报条形图 - 如何创建非堆叠起来重视

,这里是我使用它的代码:

$.getJSON('chartBar.json', function(graphDataBar){ 

    $.plot($('#graph-bars'), graphDataBar, { 
     series: { 
      bars: { 
       show: true, 
       barWidth: .1, 
       align: 'right' 


      }, 
      shadowSize: 0 
     }, 
     grid: { 
      color: '#646464', 
      borderColor: 'transparent', 
      borderWidth: 20, 
      hoverable: true 
     }, 
     xaxis: { 
      tickColor: 'transparent', 
      ticks: [[6,'Week 48'],[7,'Week 49'],[8,'Week 50'],[9,'Week 51'],[10,'Week 52']], 
      min: 5.5, 
      max: 10.5, 
      mode: 'time', 
     timeformat: "%b %d", 
     minTickSize: [1, "day"], 
     tickSize: [1, "day"], 
     autoscaleMargin: .10 
     }, 
     yaxis: { 
      tickSize: 5 
     } 
    }); 

我已经尽力用x轴内部的性质,但似乎没有任何帮助。 我知道有一种方法可以做到这一点,我见过的例子如This之一。 但它似乎没有工作。 什么我试着在这里获得成功是这个 enter image description here

除了我见过的其他样品#2像This 但它仍然没有工作了。我不知道我是否看到了这种错误的方式,或者如果我需要使用时间戳来使其工作,但我做错了方式。

任何人都可以向我解释,该解决方案将如何工作?我想了解它为未来的条形图

预先感谢您

+0

你需要一个并排端插件这样的:https://github.com/pkoltermann/SideBySideImproved – Raidri

+0

您发布数据的任何机会(chartBar.json文件)? –

回答

0

我做了一个假设,即JSON数据是一样的在你的另一个问题here所以道歉,如果不是这种情况。

我创建了一个小提琴here演示“非堆叠条形”使用下面的JSON数据:

[ 
    {  
     "data": [ [6, 520], [7, 600], [8, 850], [9, 900], [10, 300] ], 
     "color": "#F02626", 
     "points": { "fillColor": "#F02626", "radius": 6 }, 
     "lines": { "fillColor": "#CCF8FF"} 
    }, 
    { 
     "data": [ [6, 300], [7, 400], [8, 550], [9, 750], [10, 200] ], 
     "color": "#26F041", 
     "points": { "radius": 10, "fillColor": "#26F041" } 
    }, 
    { 
     "data": [ [6, 200], [7, 150], [8, 380], [9, 400], [10, 100] ], 
     "color": "#20AEFA", 
     "points": { "radius": 6, "fillColor": "#20AEFA"} 
    } 
] 

它使用orderBars plugin。以获得条的键,会出现由方(而非垂直)是设置series.bars.order属性1侧:

series: { 
    bars: { 
     ... 
     order: 1 
    } 
}, 
相关问题