作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个显示上周数据的校准热图。每行代表一天,每列代表一个小时。我有日期标签,但没有时间标签。我怎样才能添加这些?
var cal = new CalHeatMap();
cal.init({
itemSelector: "#cal-heatmap",
domain: "day",
subDomain: "hour",
rowLimit: 1,
domainGutter: 0,
data: data,
start: new Date(_.keys(data)[0] * 1000),
cellSize: 15,
cellPadding: 5,
cellRadius: 3,
range: 7,
verticalOrientation: true,
displayLegend: false,
label: {
position: "left",
offset: {
x: 20,
y: 12
},
width: 110
},
legend: [40, 80, 120, 160, 200, 240, 280, 320],
legendColors: ["#f9eb49", "#d66938"]
});
最佳答案
根据作者的说法,这还不可能,所以我想出了一个看起来不错的解决方法。我刚刚在主校准热图上方制作了另一个 div,它显示带有空标签的单行,以便它与下表对齐。然后我用下面的代码填充它:
var labels = new CalHeatMap();
labels.init({
itemSelector: "#cal-heatmap-labels",
domain: "day",
subDomain: "hour",
rowLimit: 1,
domainGutter: 0,
data: {},
cellSize: 15,
cellPadding: 5,
cellRadius: 3,
range: 1,
verticalOrientation: true,
displayLegend: false,
tooltip: true,
subDomainTextFormat: "%-I",
subDomainDateFormat: "%-I%p",
domainLabelFormat: "",
label: {
position: "left",
offset: {
x: 20,
y: 12
},
width: 110
}
});
这对我有用,看起来还不错。希望这至少可以在开发此功能之前对某人有所帮助。
关于javascript - 如何向 cal-heatmap 中的子域添加标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36091680/
我是一名优秀的程序员,十分优秀!