score:0
Ok, i have been trying a milloin things here, and i kind of got it closer to what i was looking for. Thought i would share the results here.
I dropped the d3-timeline library in this version. There is still room for improvement, but this solves the question i first asked.
//Defining the trips
var myTrips = [{
"day": 1,
"post": 101,
"title": "First day"
}, {
"day": 2,
"post": 102,
"title": "Second day"
}, {
"day": 3,
"post": 103,
"title": "Third day"
}, {
"day": 5,
"post": 103,
"title": "Third day"
}, {
"day": 12,
"post": 103,
"title": "Third day"
}, {
"day": 13,
"post": 103,
"title": "Third day"
}, {
"day": 15,
"post": 104,
"title": "Forth day"
}, {
"day": 17,
"post": 104,
"title": "Forth day"
}, {
"day": 18,
"post": 104,
"title": "Forth day"
}, {
"day": 22,
"post": 104,
"title": "Forth day"
}, {
"day": 24,
"post": 104,
"title": "Forth day"
}, {
"day": 25,
"post": 104,
"title": "Forth day"
}, {
"day": 30,
"post": 104,
"title": "Forth day"
}, {
"day": 31,
"post": 104,
"title": "Forth day"
}, {
"day": 32,
"post": 104,
"title": "Forth day"
}, {
"day": 33,
"post": 104,
"title": "Forth day"
}, {
"day": 34,
"post": 104,
"title": "Forth day"
}, {
"day": 36,
"post": 104,
"title": "Forth day"
}, {
"day": 37,
"post": 104,
"title": "Forth day"
}, {
"day": 38,
"post": 104,
"title": "Forth day"
}, {
"day": 39,
"post": 104,
"title": "Forth day"
}, {
"day": 45,
"post": 104,
"title": "Forth day"
}, {
"day": 46,
"post": 104,
"title": "Forth day"
}, {
"day": 47,
"post": 104,
"title": "Forth day"
}, {
"day": 50,
"post": 104,
"title": "Forth day"
}, {
"day": 55,
"post": 104,
"title": "Forth day"
}, {
"day": 56,
"post": 104,
"title": "Forth day"
}, {
"day": 58,
"post": 104,
"title": "Forth day"
}, {
"day": 59,
"post": 104,
"title": "Forth day"
}, {
"day": 60,
"post": 104,
"title": "Forth day"
}, {
"day": 62,
"post": 104,
"title": "Forth day"
}, {
"day": 64,
"post": 104,
"title": "Forth day"
}, {
"day": 65,
"post": 104,
"title": "Forth day"
}, {
"day": 78,
"post": 104,
"title": "Forth day"
}, {
"day": 79,
"post": 104,
"title": "Forth day"
}];
function x(d) {
return d.day;
}
var collection_array = d3.values(myTrips);
maximum = d3.max(collection_array, function(d) {
return d.day
});
var maxnum = 80;
var margin = {
top: 0,
right: 15,
bottom: 0,
left: 15
},
width = 615,
height = 40,
radius = 8;
var xScale = d3.fisheye.scale(d3.scale.linear).domain([0, maximum + 1]).range([0, width]);
var tooltip = d3.select("#infobox")
.append("div")
.attr("class", "infocontent")
.style("z-index", "10")
.style("visibility", "hidden");
var xAxis = d3.svg.axis().orient("bottom").scale(xScale).tickFormat(d3.format(",d")).tickSize(-height);
var svg = d3.select("#timeline").append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
svg.append("rect")
.attr("class", "background")
.attr("width", width)
.attr("height", height);
//Add the x-axis.
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis);
var dot = svg.append("g")
.attr("class", "dots")
.selectAll(".dot")
.data(myTrips)
.enter().append("circle")
.attr("class", "dot")
.style("fill", "green")
.attr("r", function(d) {
d.r
})
.call(position)
.on("mouseover", function(d) {
d3.select(this).style("fill", "red");
return tooltip.style("visibility", "visible").text('Day ' + d.day + ' - ' + d.title);
})
.on("mouseout", function() {
d3.select(this).style("fill", "green");
return tooltip.style("visibility", "hidden");
});
// Add a title.
dot.append("title")
.text(function(d) {
return d.title;
});
// Positions the dots based on data.
function position(dot) {
dot.attr("cx", function(d) {
return xScale(x(d));
})
.attr("cy", height / 2)
.attr("r", radius);
}
svg.on("mousemove", function() {
var mouse = d3.mouse(this);
xScale.distortion(5).focus(mouse[0]);
dot.call(position);
svg.select(".x.axis").call(xAxis);
})
.on("mouseout", function() {
var mouse = d3.mouse(this);
xScale.distortion(0).focus(mouse[0]);
dot.call(position);
svg.select(".x.axis").call(xAxis);
});
var totalRows = 80;
html {
font-family: OpenSans;
font-size: 12px;
}
.background {
fill: none;
pointer-events: all;
}
#timeline {
width: 630px;
}
#timeline .background {
fill: white;
}
#timeline .dot {
stroke: white;
}
.axis path,
.axis line {
fill: none;
stroke: none;
shape-rendering: crispEdges;
}
#infobox {
width: 630px;
}
.infocontent {
position: relative;
background: #88b7d5;
border: 4px solid #c2e1f5;
top: 10px;
padding: 10px;
}
.infocontent:after,
.infocontent:before {
bottom: 100%;
left: 50%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
}
.infocontent:after {
border-color: rgba(136, 183, 213, 0);
border-bottom-color: #88b7d5;
border-width: 10px;
margin-left: -10px;
}
.infocontent:before {
border-color: rgba(194, 225, 245, 0);
border-bottom-color: #c2e1f5;
border-width: 16px;
margin-left: -16px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.4.11/d3.min.js"></script>
<script src="http://x.resdagboken.se/js/fisheye.js"></script>
<div id="timeline"></div>
<div id="infobox"></div>
Source: stackoverflow.com
Related Query
- Fisheye effect on timeline
- Fisheye effect D3js image slideshow works on rects/objects but not image files, Error: <image> attribute x: Expected length, "NaN"
- Fisheye effect with force-directed graph : not taking effect until the graph settles
- Unable to add Fisheye effect to Labels in Forced Labelled Layout using D3.js
- Draw simple timeline with D3
- What does the "System" category of records mean in Chrome Timeline profiling tool?
- brush on rotated lines using d3 to create zoom effect
- d3js timeline chart - with one rectangle block for a scrub
- Magnifier effect for D3/GraphGL force directed network visualization?
- Cartesian distortion effect with CSS
- How is this nice D3.js scattergraph highlighting effect achieved?
- How to zoom in/out d3.time.scale without scaling other shapes bound to timeline
- transformation issues when implementing fisheye distortion in a radial tree
- Weird behaviour of Fisheye Distortion plugin
- Bouncing effect in d3
- Glowing/Flashing Effect on SVG D3js
- Creating a D3.js scatterplot with timeline using 'month-year' date values
- How to do a timeline graph similar to GitHub using D3?
- Setting d3.curveBundle.beta seems to have no effect
- Clustering timeline data in d3
- Slice and bounce effect not working properly in pie chart
- d3.slider and dates filtered on a timeline
- D3 Timeline CSV Data
- d3.js: Pie Chart Layout - Adjusting the Angle to Create Shutter Effect
- D3 fisheye on width on bar chart
- Using d3 Timeline with Angular
- How to achieve magnifying square effect for D3 charts?
- parametrize the bounceOut ease effect in D3
- CSS3 3D flip card effect with SVG elements
- Achieve transition effect of an element using d3.js
More Query from same tag
- How to extract common methods into a function
- Only last Y-axis is being updated while dragging on d3 chart
- D3 Horizontal bar graph's bars not all appearing
- No 'Access-Control-Allow-Origin' header is present on the requested resource Error when loading JSON file
- How to Set D3 Funnel Chart Label Legend
- Avoid dx/dy attributes in d3 axis labels
- D3: Cannot append simple path to svg container
- list will not go under d3.js graph
- Why is my tooltip in a wrong position?
- How to add specific colors to data in JSON with d3.js
- D3-Force updating parameters after initializing graph
- Setting static number of ticks for a chart in NVD3 and ClojureScript
- How to add label to visualization in d3
- Single Axis Zoom in D3 & React
- make edges of donut curvy
- Placing a circle over a sparkline when the user changes the ordering of the data
- Javascript code editor with intelligence
- How to transform and rotate the rectangles on partition layout in d3.js
- How to create a dynamic bar chart in d3.js?
- Problems Passing JSON from Flask Template to HTML to Static JS Script
- Undefined is not a function error d3js
- How do I reshape my existing JSON to fit Highcharts
- Cubism.js - range to color mapping
- How to use d3.js chart with data from coingeckoapi (json)
- D3: How to draw multiple Convex hulls on Groups of Force layout nodes?
- d3.js div tooltip not appearing anymore in wordpress
- D3js Force Directed Graph Link not found
- csv data to nested json tree in d3
- d3.js: why doesn't the data update?
- loading json through javascript/D3