Commit b3b6c239 authored by amarcic's avatar amarcic
Browse files

timeline, labels: added basic height dependent rendering of labels

parent 359f4a54
......@@ -87,8 +87,8 @@ export const Histogram = (props) => {
.style("transform", "scale(1,-1)")
.attr("width", x.bandwidth())
.on("mouseenter", (event, value) => {
const element = svg.selectAll(".bar").nodes();
const index = element.indexOf(event.target);
//const element = svg.selectAll(".bar").nodes();
//const index = element.indexOf(event.target);
//console.log(value);
svg
.selectAll(".tooltip")
......
......@@ -136,7 +136,22 @@ export const TimelineChart = (props) => {
.attr("y", (value, index) => yScale(periodIds[index]))
.attr("width", value => Math.abs(xScale(value.periodSpan?.[0])-xScale(value.periodSpan?.[1]))||0)
if(yScale.bandwidth()<=4)
selectionEnteringAndUpdating
.on("mouseenter", (event, value) => {
svg
.selectAll(".tooltip")
.data([value])
.join("text")
.attr("class", "tooltip")
.text(`${value.periodName}`)
.attr("text-anchor", "middle")
.attr("x", value => xScale(value.periodSpan?.[0]))
.attr("y", value => yScale(value.periodId))
});
//add labels to the bars
if(yScale.bandwidth()>4)
selectionLabels
.enter()
.append("text")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment