我想通过highcharts复制github上呈现的“打卡”样式图。使用Highcharts.js创建打卡风格图
我真的与这一个挣扎,这里有一个jsfiddle启动让我在那里。我宁愿在X和Y上有几天的时间,但我对如何去做这件事感到茫然。
任何帮助表示赞赏。
TIA!
我想通过highcharts复制github上呈现的“打卡”样式图。使用Highcharts.js创建打卡风格图
我真的与这一个挣扎,这里有一个jsfiddle启动让我在那里。我宁愿在X和Y上有几天的时间,但我对如何去做这件事感到茫然。
任何帮助表示赞赏。
TIA!
我无法翻转轴,但为您整理了很多东西。
HTML:
<div id="container" style="height: 400px"></div>
JS:
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
defaultSeriesType: 'scatter'
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
yAxis: {
},
plotOptions: {
scatter: {
marker: {
radius: 4,
states: {
hover: {
enabled: true,
lineColor: 'rgb(100,100,100)'
}
}
},
states: {
hover: {
marker: {
enabled: false
}
}
}
}
},
series: [{
data: [{y: 161}, {y: 167}, {y: 165}, {y: 140}, {y: 172}, {y: 163}, {y: 187}, {y: 107}, {y: 147}, {y: 145}, {y: 112}, {y: 199}]
}]
});
超级关闭 - 非常感谢。如果我能弄清楚如何在y轴上显示00:00到24:00的时间,那么这将是一个胜利者。我更新了小提琴以在x轴上显示Sun-Sat。感谢让我更接近。 – 2012-02-14 15:40:36
我很高兴我有帮助,虽然投票会非常令人鼓舞:P **开玩笑**。会试图寻求进一步改善。 – 2012-02-14 18:10:42
我从@mangobug updated the jsFiddle引导你做你想要
'未捕获的ReferenceError:没有定义Highcharts' – 2017-07-07 14:53:00
什么的更紧密的方式,我想这是到现在为止,但也许这种解决方案将帮助其他人在相同的情况。
这里是我的解决方案:
$(function() {
$('#container').highcharts({
chart: {
defaultSeriesType: 'scatter'
},
title: {
text: 'Punchcard'
},
xAxis: {
type: "datetime",
dateTimeLabelFormats: {
hour: '%I %P'
},
tickInterval: 3600000 * 1
},
yAxis: {
categories: ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],
},
series: [{
data: [
{y: 0, x: 3600000 * 1, marker: { radius: Math.floor(Math.random()*11) }},
{y: 0, x: 3600000 * 2, marker: { radius: Math.floor(Math.random()*11) }},
{y: 0, x: 3600000 * 3, marker: { radius: Math.floor(Math.random()*11) }},
{y: 0, x: 3600000 * 4, marker: { radius: Math.floor(Math.random()*11) }},
{y: 0, x: 3600000 * 5, marker: { radius: Math.floor(Math.random()*11) }},
{y: 0, x: 3600000 * 6, marker: { radius: Math.floor(Math.random()*11) }},
{y: 0, x: 3600000 * 7, marker: { radius: Math.floor(Math.random()*11) }},
{y: 0, x: 3600000 * 8, marker: { radius: Math.floor(Math.random()*11) }},
{y: 0, x: 3600000 * 9, marker: { radius: Math.floor(Math.random()*11) }},
{y: 0, x: 3600000 * 10, marker: { radius: Math.floor(Math.random()*11) }},
{y: 0, x: 3600000 * 11, marker: { radius: Math.floor(Math.random()*11) }},
{y: 0, x: 3600000 * 12, marker: { radius: Math.floor(Math.random()*11) }},
{y: 0, x: 3600000 * 13, marker: { radius: Math.floor(Math.random()*11) }},
{y: 0, x: 3600000 * 14, marker: { radius: Math.floor(Math.random()*11) }},
{y: 0, x: 3600000 * 15, marker: { radius: Math.floor(Math.random()*11) }},
{y: 0, x: 3600000 * 16, marker: { radius: Math.floor(Math.random()*11) }},
{y: 0, x: 3600000 * 17, marker: { radius: Math.floor(Math.random()*11) }},
{y: 0, x: 3600000 * 18, marker: { radius: Math.floor(Math.random()*11) }},
{y: 0, x: 3600000 * 19, marker: { radius: Math.floor(Math.random()*11) }},
{y: 0, x: 3600000 * 20, marker: { radius: Math.floor(Math.random()*11) }},
{y: 0, x: 3600000 * 21, marker: { radius: Math.floor(Math.random()*11) }},
{y: 0, x: 3600000 * 22, marker: { radius: Math.floor(Math.random()*11) }},
{y: 0, x: 3600000 * 23, marker: { radius: Math.floor(Math.random()*11) }},
{y: 1, x: 3600000 * 1, marker: { radius: Math.floor(Math.random()*11) }},
{y: 1, x: 3600000 * 2, marker: { radius: Math.floor(Math.random()*11) }},
{y: 1, x: 3600000 * 3, marker: { radius: Math.floor(Math.random()*11) }},
{y: 1, x: 3600000 * 4, marker: { radius: Math.floor(Math.random()*11) }},
{y: 1, x: 3600000 * 5, marker: { radius: Math.floor(Math.random()*11) }},
{y: 1, x: 3600000 * 6, marker: { radius: Math.floor(Math.random()*11) }},
{y: 1, x: 3600000 * 7, marker: { radius: Math.floor(Math.random()*11) }},
{y: 1, x: 3600000 * 8, marker: { radius: Math.floor(Math.random()*11) }},
{y: 1, x: 3600000 * 9, marker: { radius: Math.floor(Math.random()*11) }},
{y: 1, x: 3600000 * 10, marker: { radius: Math.floor(Math.random()*11) }},
{y: 1, x: 3600000 * 11, marker: { radius: Math.floor(Math.random()*11) }},
{y: 1, x: 3600000 * 12, marker: { radius: Math.floor(Math.random()*11) }},
{y: 1, x: 3600000 * 13, marker: { radius: Math.floor(Math.random()*11) }},
{y: 1, x: 3600000 * 14, marker: { radius: Math.floor(Math.random()*11) }},
{y: 1, x: 3600000 * 15, marker: { radius: Math.floor(Math.random()*11) }},
{y: 1, x: 3600000 * 16, marker: { radius: Math.floor(Math.random()*11) }},
{y: 1, x: 3600000 * 17, marker: { radius: Math.floor(Math.random()*11) }},
{y: 1, x: 3600000 * 18, marker: { radius: Math.floor(Math.random()*11) }},
{y: 1, x: 3600000 * 19, marker: { radius: Math.floor(Math.random()*11) }},
{y: 1, x: 3600000 * 20, marker: { radius: Math.floor(Math.random()*11) }},
{y: 1, x: 3600000 * 21, marker: { radius: Math.floor(Math.random()*11) }},
{y: 1, x: 3600000 * 22, marker: { radius: Math.floor(Math.random()*11) }},
{y: 1, x: 3600000 * 23, marker: { radius: Math.floor(Math.random()*11) }},
{y: 2, x: 3600000 * 1, marker: { radius: Math.floor(Math.random()*11) }},
{y: 2, x: 3600000 * 2, marker: { radius: Math.floor(Math.random()*11) }},
{y: 2, x: 3600000 * 3, marker: { radius: Math.floor(Math.random()*11) }},
{y: 2, x: 3600000 * 4, marker: { radius: Math.floor(Math.random()*11) }},
{y: 2, x: 3600000 * 5, marker: { radius: Math.floor(Math.random()*11) }},
{y: 2, x: 3600000 * 6, marker: { radius: Math.floor(Math.random()*11) }},
{y: 2, x: 3600000 * 7, marker: { radius: Math.floor(Math.random()*11) }},
{y: 2, x: 3600000 * 8, marker: { radius: Math.floor(Math.random()*11) }},
{y: 2, x: 3600000 * 9, marker: { radius: Math.floor(Math.random()*11) }},
{y: 2, x: 3600000 * 10, marker: { radius: Math.floor(Math.random()*11) }},
{y: 2, x: 3600000 * 11, marker: { radius: Math.floor(Math.random()*11) }},
{y: 2, x: 3600000 * 12, marker: { radius: Math.floor(Math.random()*11) }},
{y: 2, x: 3600000 * 13, marker: { radius: Math.floor(Math.random()*11) }},
{y: 2, x: 3600000 * 14, marker: { radius: Math.floor(Math.random()*11) }},
{y: 2, x: 3600000 * 15, marker: { radius: Math.floor(Math.random()*11) }},
{y: 2, x: 3600000 * 16, marker: { radius: Math.floor(Math.random()*11) }},
{y: 2, x: 3600000 * 17, marker: { radius: Math.floor(Math.random()*11) }},
{y: 2, x: 3600000 * 18, marker: { radius: Math.floor(Math.random()*11) }},
{y: 2, x: 3600000 * 19, marker: { radius: Math.floor(Math.random()*11) }},
{y: 2, x: 3600000 * 20, marker: { radius: Math.floor(Math.random()*11) }},
{y: 2, x: 3600000 * 21, marker: { radius: Math.floor(Math.random()*11) }},
{y: 2, x: 3600000 * 22, marker: { radius: Math.floor(Math.random()*11) }},
{y: 2, x: 3600000 * 23, marker: { radius: Math.floor(Math.random()*11) }},
{y: 3, x: 3600000 * 1, marker: { radius: Math.floor(Math.random()*11) }},
{y: 3, x: 3600000 * 2, marker: { radius: Math.floor(Math.random()*11) }},
{y: 3, x: 3600000 * 3, marker: { radius: Math.floor(Math.random()*11) }},
{y: 3, x: 3600000 * 4, marker: { radius: Math.floor(Math.random()*11) }},
{y: 3, x: 3600000 * 5, marker: { radius: Math.floor(Math.random()*11) }},
{y: 3, x: 3600000 * 6, marker: { radius: Math.floor(Math.random()*11) }},
{y: 3, x: 3600000 * 7, marker: { radius: Math.floor(Math.random()*11) }},
{y: 3, x: 3600000 * 8, marker: { radius: Math.floor(Math.random()*11) }},
{y: 3, x: 3600000 * 9, marker: { radius: Math.floor(Math.random()*11) }},
{y: 3, x: 3600000 * 10, marker: { radius: Math.floor(Math.random()*11) }},
{y: 3, x: 3600000 * 11, marker: { radius: Math.floor(Math.random()*11) }},
{y: 3, x: 3600000 * 12, marker: { radius: Math.floor(Math.random()*11) }},
{y: 3, x: 3600000 * 13, marker: { radius: Math.floor(Math.random()*11) }},
{y: 3, x: 3600000 * 14, marker: { radius: Math.floor(Math.random()*11) }},
{y: 3, x: 3600000 * 15, marker: { radius: Math.floor(Math.random()*11) }},
{y: 3, x: 3600000 * 16, marker: { radius: Math.floor(Math.random()*11) }},
{y: 3, x: 3600000 * 17, marker: { radius: Math.floor(Math.random()*11) }},
{y: 3, x: 3600000 * 18, marker: { radius: Math.floor(Math.random()*11) }},
{y: 3, x: 3600000 * 19, marker: { radius: Math.floor(Math.random()*11) }},
{y: 3, x: 3600000 * 20, marker: { radius: Math.floor(Math.random()*11) }},
{y: 3, x: 3600000 * 21, marker: { radius: Math.floor(Math.random()*11) }},
{y: 3, x: 3600000 * 22, marker: { radius: Math.floor(Math.random()*11) }},
{y: 3, x: 3600000 * 23, marker: { radius: Math.floor(Math.random()*11) }},
{y: 4, x: 3600000 * 1, marker: { radius: Math.floor(Math.random()*11) }},
{y: 4, x: 3600000 * 2, marker: { radius: Math.floor(Math.random()*11) }},
{y: 4, x: 3600000 * 3, marker: { radius: Math.floor(Math.random()*11) }},
{y: 4, x: 3600000 * 4, marker: { radius: Math.floor(Math.random()*11) }},
{y: 4, x: 3600000 * 5, marker: { radius: Math.floor(Math.random()*11) }},
{y: 4, x: 3600000 * 6, marker: { radius: Math.floor(Math.random()*11) }},
{y: 4, x: 3600000 * 7, marker: { radius: Math.floor(Math.random()*11) }},
{y: 4, x: 3600000 * 8, marker: { radius: Math.floor(Math.random()*11) }},
{y: 4, x: 3600000 * 9, marker: { radius: Math.floor(Math.random()*11) }},
{y: 4, x: 3600000 * 10, marker: { radius: Math.floor(Math.random()*11) }},
{y: 4, x: 3600000 * 11, marker: { radius: Math.floor(Math.random()*11) }},
{y: 4, x: 3600000 * 12, marker: { radius: Math.floor(Math.random()*11) }},
{y: 4, x: 3600000 * 13, marker: { radius: Math.floor(Math.random()*11) }},
{y: 4, x: 3600000 * 14, marker: { radius: Math.floor(Math.random()*11) }},
{y: 4, x: 3600000 * 15, marker: { radius: Math.floor(Math.random()*11) }},
{y: 4, x: 3600000 * 16, marker: { radius: Math.floor(Math.random()*11) }},
{y: 4, x: 3600000 * 17, marker: { radius: Math.floor(Math.random()*11) }},
{y: 4, x: 3600000 * 18, marker: { radius: Math.floor(Math.random()*11) }},
{y: 4, x: 3600000 * 19, marker: { radius: Math.floor(Math.random()*11) }},
{y: 4, x: 3600000 * 20, marker: { radius: Math.floor(Math.random()*11) }},
{y: 4, x: 3600000 * 21, marker: { radius: Math.floor(Math.random()*11) }},
{y: 4, x: 3600000 * 22, marker: { radius: Math.floor(Math.random()*11) }},
{y: 4, x: 3600000 * 23, marker: { radius: Math.floor(Math.random()*11) }},
{y: 5, x: 3600000 * 1, marker: { radius: Math.floor(Math.random()*11) }},
{y: 5, x: 3600000 * 2, marker: { radius: Math.floor(Math.random()*11) }},
{y: 5, x: 3600000 * 3, marker: { radius: Math.floor(Math.random()*11) }},
{y: 5, x: 3600000 * 4, marker: { radius: Math.floor(Math.random()*11) }},
{y: 5, x: 3600000 * 5, marker: { radius: Math.floor(Math.random()*11) }},
{y: 5, x: 3600000 * 6, marker: { radius: Math.floor(Math.random()*11) }},
{y: 5, x: 3600000 * 7, marker: { radius: Math.floor(Math.random()*11) }},
{y: 5, x: 3600000 * 8, marker: { radius: Math.floor(Math.random()*11) }},
{y: 5, x: 3600000 * 9, marker: { radius: Math.floor(Math.random()*11) }},
{y: 5, x: 3600000 * 10, marker: { radius: Math.floor(Math.random()*11) }},
{y: 5, x: 3600000 * 11, marker: { radius: Math.floor(Math.random()*11) }},
{y: 5, x: 3600000 * 12, marker: { radius: Math.floor(Math.random()*11) }},
{y: 5, x: 3600000 * 13, marker: { radius: Math.floor(Math.random()*11) }},
{y: 5, x: 3600000 * 14, marker: { radius: Math.floor(Math.random()*11) }},
{y: 5, x: 3600000 * 15, marker: { radius: Math.floor(Math.random()*11) }},
{y: 5, x: 3600000 * 16, marker: { radius: Math.floor(Math.random()*11) }},
{y: 5, x: 3600000 * 17, marker: { radius: Math.floor(Math.random()*11) }},
{y: 5, x: 3600000 * 18, marker: { radius: Math.floor(Math.random()*11) }},
{y: 5, x: 3600000 * 19, marker: { radius: Math.floor(Math.random()*11) }},
{y: 5, x: 3600000 * 20, marker: { radius: Math.floor(Math.random()*11) }},
{y: 5, x: 3600000 * 21, marker: { radius: Math.floor(Math.random()*11) }},
{y: 5, x: 3600000 * 22, marker: { radius: Math.floor(Math.random()*11) }},
{y: 5, x: 3600000 * 23, marker: { radius: Math.floor(Math.random()*11) }},
{y: 6, x: 3600000 * 1, marker: { radius: Math.floor(Math.random()*11) }},
{y: 6, x: 3600000 * 2, marker: { radius: Math.floor(Math.random()*11) }},
{y: 6, x: 3600000 * 3, marker: { radius: Math.floor(Math.random()*11) }},
{y: 6, x: 3600000 * 4, marker: { radius: Math.floor(Math.random()*11) }},
{y: 6, x: 3600000 * 5, marker: { radius: Math.floor(Math.random()*11) }},
{y: 6, x: 3600000 * 6, marker: { radius: Math.floor(Math.random()*11) }},
{y: 6, x: 3600000 * 7, marker: { radius: Math.floor(Math.random()*11) }},
{y: 6, x: 3600000 * 8, marker: { radius: Math.floor(Math.random()*11) }},
{y: 6, x: 3600000 * 9, marker: { radius: Math.floor(Math.random()*11) }},
{y: 6, x: 3600000 * 10, marker: { radius: Math.floor(Math.random()*11) }},
{y: 6, x: 3600000 * 11, marker: { radius: Math.floor(Math.random()*11) }},
{y: 6, x: 3600000 * 12, marker: { radius: Math.floor(Math.random()*11) }},
{y: 6, x: 3600000 * 13, marker: { radius: Math.floor(Math.random()*11) }},
{y: 6, x: 3600000 * 14, marker: { radius: Math.floor(Math.random()*11) }},
{y: 6, x: 3600000 * 15, marker: { radius: Math.floor(Math.random()*11) }},
{y: 6, x: 3600000 * 16, marker: { radius: Math.floor(Math.random()*11) }},
{y: 6, x: 3600000 * 17, marker: { radius: Math.floor(Math.random()*11) }},
{y: 6, x: 3600000 * 18, marker: { radius: Math.floor(Math.random()*11) }},
{y: 6, x: 3600000 * 19, marker: { radius: Math.floor(Math.random()*11) }},
{y: 6, x: 3600000 * 20, marker: { radius: Math.floor(Math.random()*11) }},
{y: 6, x: 3600000 * 21, marker: { radius: Math.floor(Math.random()*11) }},
{y: 6, x: 3600000 * 22, marker: { radius: Math.floor(Math.random()*11) }},
{y: 6, x: 3600000 * 23, marker: { radius: Math.floor(Math.random()*11) }},
]
}]
});
});
这里是演示:http://jsfiddle.net/KmPJE/1/
让我知道这是否为你的作品。
真的不错的工作 - 在旧帖子上很好的跟进。 – 2013-07-02 02:59:39
没问题!我目前正在使用气泡图而不是散点图来更好地进行研究。 – kerberoS 2013-07-02 04:10:04
更新了jsfiddle,并修改了mangobug的建议。剩下的就是在y轴上花时间。 – 2012-02-14 15:41:23
这是另一个更新,它可以获得y和x轴标签的所需:http://jsfiddle.net/CA2cT/8/ – Mark 2012-02-14 22:33:13
完美的完成!感谢你拖过那条线。 – 2012-02-15 15:21:45