D3.js Chart: Labels ( Tags) Not Showing On IE11

前端 未结 2 403
傲寒
傲寒 2021-01-04 01:02

I have a stacked bar chart whose labels will not show on IE, but will on Chrome and Firefox.

The labels I have on the stacked bar charts ar

2条回答
  •  盖世英雄少女心
    2021-01-04 01:53

    In case anyone is still suffering with this issue, I've come across a solution that works in many cases.

    If the width of the svg element changes, IE will repaint the SVG element, which will correct a misplaced element. If the svg is set to 100% of its container div's width through the style attribute, a negligible change to the svg's width will not be visibly obvious, but is enough to repaint.

    The width (and height) of the enclosing element can be used to set the svg's desired dimensions.

    // HTML
    
    // JS var svgEl = document.getElementById( 'mySVG' ) svgEl.style.width = '99.9%' // can be any % other than that initially set on the svg

提交回复
热议问题