Make calendar only clickable, if counts > 0

This commit is contained in:
Henrik Giesel 2021-01-18 02:09:04 +01:00
parent 60ed9c1e22
commit f767a5e6ca
2 changed files with 18 additions and 4 deletions

View File

@ -114,7 +114,7 @@ export function renderCalendar(
maxCount = count;
}
}
console.log('sourceData', sourceData, dayMap)
console.log("sourceData", sourceData, dayMap);
if (!maxCount) {
setDataAvailable(svg, false);
@ -207,8 +207,13 @@ export function renderCalendar(
showTooltip(tooltipText(d), x, y);
})
.on("mouseout", hideTooltip)
.attr("class", (d: any): string => {
return d.count > 0 ? "clickable" : "";
})
.on("click", function (this: any, d: any) {
if (d.count > 0) {
dispatch("search", { query: `"prop:rated=${d.day}"` });
}
})
.transition()
.duration(800)

View File

@ -64,7 +64,7 @@ export function prepareData(
function makeQuery(data: HistogramData, binIdx: number): string {
const bin = data.bins[binIdx];
const start = bin.x0!;
const end = (bin.x1! - 1);
const end = bin.x1! - 1;
if (start === end) {
return `"prop:ease=${start / 100}"`;
@ -85,7 +85,16 @@ export function prepareData(
];
return [
{ scale, bins, total, hoverText, makeQuery, colourScale, showArea: false, xTickFormat },
{
scale,
bins,
total,
hoverText,
makeQuery,
colourScale,
showArea: false,
xTickFormat,
},
tableData,
];
}