【发布时间】:2016-06-08 04:24:39
【问题描述】:
我有一个堆积柱形图,x 轴上的日期时间不规则。日期时间间隔可以是任意的。基本上,我们的爬虫会定期从不同的 api 插入数据,但在某些情况下它会在某些日期失败。所以日期时间大多是不规则的。
看看下面的例子。
- 我需要删除那些自动添加的点 高图。
- 我需要在 x 轴上放置精确的点日期。
- 我需要 x 轴与列对齐。目前x轴上的日期是 未对齐。
$(function () {
var chart;
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
plotBorderWidth: 1,
type: "column",
},
title: {
text: ""
},
xAxis: {
type: "datetime",
tickLength: 0,
},
yAxis: {
min: 0,
title: {
text: "Keywords"
},
stackLabels: {
enabled: false,
style: {
fontWeight: "bold",
color: "gray"
}
},
opposite: false
},
legend: {
backgroundColor: "white",
borderColor: "#CCC",
borderWidth: 0,
shadow: false
},
plotOptions: {
column: {
stacking: 'normal'
},
},
series: [{
name: "Ranked on Page 3",
data: [{
y: 2,
x: 1449532800000,
pointDate: 1449532800000
}, {
y: 4,
x: 1450137600000,
pointDate: 1450137600000
}, {
y: 3,
x: 1450742400000,
pointDate: 1450742400000
}, {
y: 3,
x: 1451347200000,
pointDate: 1451347200000
}, {
y: 2,
x: 1454025600000,
pointDate: 1454025600000
}],
maxPointWidth: 100
}, {
name: "Ranked on Page 2",
data: [{
y: 1,
x: 1449532800000,
pointDate: 1449532800000
}],
maxPointWidth: 100
}, {
name: "Ranked on Page 1",
data: [{
y: 2,
x: 1454025600000,
pointDate: 1454025600000
}],
maxPointWidth: 100
}],
colors: ["#6662AC", "#57B3C8", "#F7971E"]
});
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
玩实际数据和输出:JsFiddle
任何帮助将不胜感激。
【问题讨论】:
-
highchart“自动加分”有哪些?这是什么意思?
-
这意味着,我只将 5 个日期传递给图表,并且在 12 月 28 日至 2 月 1 日之间没有数据点。它会自动考虑 7 天的日期间隔。
-
所以你是说你想要所有点之间的距离相等?无论时差如何。
-
不,我根本不需要那些积分(1 月 4 日、1 月 11 日、1 月 18 日、1 月 25 日)。或仅显示点日期的日期
-
如果我没记错的话,J-D 只想显示那些在条形悬停上显示的日期。该日期应在 x 轴上显示为绘图日期
标签: javascript highcharts