[Vuejs]-Britechart – How to add icon images to chart y axis

1👍

Issue resolved. Sharing the code to help someone in need.

https://codepen.io/cooltaiwanesesam/pen/YzyXYWE

barChart
  .isHorizontal(true)
  .width(containerWidth)
  .height(300);

barContainer.datum(dataset).call(barChart);

d3.selectAll('.y-axis-group .tick')
  .each((d, i, list) => {        
    let img = barData.data.find((item) => item.name === d).img;

    d3.select(list[i])
      .append('image')
      .attr('x', -36)
      .attr('y', -22)
      .attr('width', 42)
      .attr('height', 42)
      .attr('xlink:href', img)
  });

Reference: https://github.com/eventbrite/britecharts/issues/798 Thanks to Marcos from Britecharts.

Leave a comment