score:1
Is this what you're looking for?
Code Plunkr with mouseover resolving images (with href) as a pattern
Source for the sample images: https://developers.google.com/speed/webp/gallery
Snapshot of your data:
{
"str_lab": "A",
"num": 100,
"image": 'https://www.gstatic.com/webp/gallery3/2.png'
},
I had to rearrange a lot of svg
elements ( especially the defs
and the center circle
). Do remember that it's always recommended to append defs
with filters and patterns to the SVG
and not the <g>
element within it AND if you do, make sure the corresponding elements are transform
ed accordingly.
Here are some relevant changes in your code:
var pattern = defs.append('pattern')
.attr('id', 'image')
.attr('patternUnits', 'userSpaceOnUse')
.attr('width', 300)
.attr('height', 300);
var image = pattern.append('image').attr('x', 0).attr('y', 0).attr('width', 124)
.attr('height', 124);
Center circle on mouseover calls the pattern image set by d.data.image
:
d3.select('pattern image')
.attr('xlink:href', d.data.image);
svg.select('circle.image')
.attr('fill','url(#image)')
Hope this helps and let me know if you have any questions. :)
Source: stackoverflow.com
Related Query
- display images on mouseover for each slice
- D3.js - why mouseover and mouse out fired for each child elements?
- How to display text on donut chart for mouseover event
- How do I add bubbles on each of the y-axis values that I have and how do I add mouseover function for each of them?
- D3 mouseover effect for each chart on one page
- nvd3.js - display specific color for each bar in multibar vertical chart depending on range of value
- D3 JS - How to display data for each element on mouse over
- How to inflate data with d3.js to display an area for each datapoint
- Appending multiple non-nested elements for each data member with D3.js
- How do I display dates on the x-axis for nvd3 / d3.js?
- D3.js binding an object to data and appending for each key
- Can I use images as the background rectangles for d3 treemaps?
- Make Gist from Github repo for display on bl.ocks.org
- How to display the value for the final tick on axis in D3?
- How can I get "call" to execute for each data element in D3?
- Add region around SVG path for mouseover
- Why my D3 line graphs shows black areas for each entity?
- Where can I get the .geojson file for India and not separate files for each state/territory or any other distinction?
- d3js display arrow at the end of each axis
- How to display a text when mouseover a node in D3 force layout
- How can I connect two parent node into one child node and how to make a tooltip for each node in the tree pragmatically? in D3 js (SVG)
- d3 using a different X scale and Y scale domain for each selection
- Setting different images for D3 force-directed layout nodes
- In D3, how can I create multiple elements for each data element based on value in data?
- Dynamically display images in D3
- d3js force layout dynamically adding image or circle for each node
- d3.js: Dual lines of text for each tick on an axis?
- How to display property text on mouseover in d3 map
- D3 x-axis for each day of the week
- Specifying nodeSize for each node individually in D3.js tree layout
More Query from same tag
- D3 selection returns empty list; elements exist in DOM
- images ds3.js heatmap
- Selecting text of same color in using .select() d3js
- How to use a colorbrewer scale
- What is the meaning of attr("d", path)?
- How to add labels into the arc of a chord diagram in d3.js
- D3.js Sweep Graph
- d3.js: how to use data from the parent node? (to show the grouped bar name at the individual bar tooltip)
- How to draw mirrored x-axis(inverted) bar chart in d3?
- Rails 4: "//= require_tree ." in application.js doesn't include my js file in /app/assets/javascripts
- maintaing object constancy in transistioning donut chart
- Prob reading bar chart with d3js v7 Error: <rect> attribute height: Expected length, "NaN"
- Drawing a from two series of data in d3
- Mapping the latitude longitude co-ordinates on Map
- Making x coordinates from string values(text) for a line graph
- D3 pie chart rendering in only one color
- d3js - Add elements based only on nested data
- Parse and upload a csv file in D3.js V5
- I cannot generate a bar chart from csv file in d3.js
- D3.js Drawing geojson incorrectly
- set maximum value for c3js scatter chart plot size
- Custom tick size on axis (d3js)
- Use an IIFE approach and pass a variable from one file to another
- d3.js v4 bar chart with negative values on y axis
- How to draw line plus bar chart using highcharts/d3.js or any other chart library?
- d3 - dougnut bubble pie chart
- kafka Rest calls + D3 animated chart
- Nested g vs svg
- Fail to parse/project coordinates onto JSON
- D3 time scales being split onto two lines