2016-01-08 58 views
0

我已经绘制了简单的水平分组条形图,我想要的是在每个酒吧上使用dimpleJs尝试很多方法的中位数和下四分位数创建一个点,但仍无法找到如何做它? enter image description here在dimplejs单杠中的中位数,下四分位数char

我的JSON数据:

var data = [{ 
    "topic_id": 38, 
    "level": "easy", 
    "all_marks": [100], 
    "total marks": 80, 
    "name": "gamma", 
    "topic label": "sec A", 
    "median" : 18, 
}, { 
    "topic_id": 38, 
    "level": "medium", 
    "all_marks": [30], 
    "total marks": 10, 
    "name": "alpha", 
    "topic label": "sec A", 
    "median" : 11, 
}, { 
    "topic_id": 38, 
    "level": "difficult", 
    "all_marks": [40], 
    "total marks": 10, 
    "median" : 15, 
    "name": "delta", 
    "topic label": "sec A" 
}, { 
    "topic_id": 39, 
    "level": "easy", 
    "all_marks": [100], 
    "total marks": 80, 
    "median" : 13, 
    "name": "gamma", 
    "topic label": "sec B" 
}, { 
    "median" : 11, 
    "topic_id": 39, 
    "level": "medium", 
    "all_marks": [30], 
    "total marks": 10, 
    "name": "alpha", 
    "topic label": "sec B" 
}, { 
    "median" : 10, 
    "topic_id": 39, 
    "level": "difficult", 
    "all_marks": [40], 
    "total marks": 10, 
    "name": "delta", 
    "topic label": "sec B" 
}]; 

回答

1

我可以看到你的数据位数,但没有下四分,如果你能得到,在该数据相同的格式为中位数将是相当简单将其添加到图表。下面是一个例子添加位数作为一个浮动标记,您可以更改系列类型的泡沫,如果你宁愿比矩形点:

// Set up the chart as usual 
var svg = dimple.newSvg("#chartContainer", 800, 600); 
var c = new dimple.chart(svg, data); 
var totalAxis = c.addMeasureAxis("x", "total marks"); 
var categoryAxis = c.addCategoryAxis("y", ["topic label", "level"]); 
// Add an additional measure axis. By passing an axis object rather than a position letter to the first parameter 
// we create a composite axis which draws both measures on the same physical axis. 
var medianAxis = c.addMeasureAxis(totalAxis, "median"); 
// Add the bar series 
var totalSeries = c.addSeries("level", dimple.plot.bar, [categoryAxis, totalAxis]); 
// Add a separate bar series for median 
var medianSeries = c.addSeries(null, dimple.plot.bar, [categoryAxis, medianAxis]); 
// By setting to not be stacked on a bar series it draws floating bars which work as markers 
medianSeries.stacked = false; 
c.draw(); 

这是在行动:https://jsfiddle.net/w9tjqq6c/

+0

你好有箱线可从dimpleJS获得? –

+0

我现在在你的代码中发现了一些问题..中位数值是随机放置在容易的中值难度级别的栏中显示? –