@@ -1652,6 +1652,9 @@ ${labelRow}`;
1652
1652
// legendEnabled to decided which index to look up.
1653
1653
// This is brittle and needs to be revisited
1654
1654
const svgRoot = chart . container . querySelector ( 'svg' ) ;
1655
+ const layout = chart . getChartLayoutInterface ( ) ;
1656
+ // remove any labels that have previously been drawn
1657
+ $ ( '.__img_labels' ) . each ( ( idx , n ) => $ ( n ) . remove ( ) ) ;
1655
1658
1656
1659
let markers ;
1657
1660
if ( legendEnabled ) {
@@ -1661,29 +1664,25 @@ ${labelRow}`;
1661
1664
}
1662
1665
if ( hasImage ) {
1663
1666
1664
- const layout = chart . getChartLayoutInterface ( ) ;
1665
- // remove any labels that have previously been drawn
1666
- $ ( '.__img_labels' ) . each ( ( idx , n ) => $ ( n ) . remove ( ) ) ;
1667
-
1668
- // for each point, (1) find the x,y location, (2) render the SVGImage,
1669
- // (3) center it on the datapoint, (4) steal all the events
1670
- // and (5) add it to the chart
1671
- combined . forEach ( ( p , i ) => {
1672
- get ( p , 'ps' ) . filter ( p => p [ 3 ] ) . forEach ( ( p , i ) => {
1673
- const xPos = layout . getXLocation ( data . getValue ( i , 0 ) ) ;
1674
- const yPos = layout . getYLocation ( data . getValue ( i , 1 ) ) ;
1675
- const imgDOM = p [ 3 ] . val . toDomNode ( ) ;
1676
- p [ 3 ] . val . render ( imgDOM . getContext ( '2d' ) , 0 , 0 ) ;
1677
- // make an image element from the SVG namespace
1678
- let imageElt = document . createElementNS ( "http://www.w3.org/2000/svg" , 'image' ) ;
1679
- imageElt . classList . add ( '__img_labels' ) ; // tag for later garbage collection
1680
- imageElt . setAttributeNS ( null , 'href' , imgDOM . toDataURL ( ) ) ;
1681
- imageElt . setAttribute ( 'x' , xPos - imgDOM . width / 2 ) ; // center the image
1682
- imageElt . setAttribute ( 'y' , yPos - imgDOM . height / 2 ) ; // center the image
1683
- Object . assign ( imageElt , markers [ i ] ) ; // we should probably not steal *everything*...
1684
- svgRoot . appendChild ( imageElt ) ;
1667
+ // for each point, (1) find the x,y location, (2) render the SVGImage,
1668
+ // (3) center it on the datapoint, (4) steal all the events
1669
+ // and (5) add it to the chart
1670
+ combined . forEach ( ( p , i ) => {
1671
+ get ( p , 'ps' ) . filter ( p => p [ 3 ] ) . forEach ( ( p , i ) => {
1672
+ const xPos = layout . getXLocation ( data . getValue ( i , 0 ) ) ;
1673
+ const yPos = layout . getYLocation ( data . getValue ( i , 1 ) ) ;
1674
+ const imgDOM = p [ 3 ] . val . toDomNode ( ) ;
1675
+ p [ 3 ] . val . render ( imgDOM . getContext ( '2d' ) , 0 , 0 ) ;
1676
+ // make an image element from the SVG namespace
1677
+ let imageElt = document . createElementNS ( "http://www.w3.org/2000/svg" , 'image' ) ;
1678
+ imageElt . classList . add ( '__img_labels' ) ; // tag for later garbage collection
1679
+ imageElt . setAttributeNS ( null , 'href' , imgDOM . toDataURL ( ) ) ;
1680
+ imageElt . setAttribute ( 'x' , xPos - imgDOM . width / 2 ) ; // center the image
1681
+ imageElt . setAttribute ( 'y' , yPos - imgDOM . height / 2 ) ; // center the image
1682
+ Object . assign ( imageElt , markers [ i ] ) ; // we should probably not steal *everything*...
1683
+ svgRoot . appendChild ( imageElt ) ;
1684
+ } ) ;
1685
1685
} ) ;
1686
- } ) ;
1687
1686
}
1688
1687
1689
1688
if ( dotChartP ) {
@@ -1705,7 +1704,7 @@ ${labelRow}`;
1705
1704
}
1706
1705
1707
1706
// compute circleY, and add a new SVG to the graph
1708
- circles . forEach ( ( circle ) => {
1707
+ circles . forEach ( ( circle , i ) => {
1709
1708
const circleX = Number ( circle . getAttribute ( 'cx' ) ) ;
1710
1709
1711
1710
// Shift the circle up by r+1, so it sits on the x-axis
@@ -1721,7 +1720,7 @@ ${labelRow}`;
1721
1720
const randomVHeight = ( 1 - Math . random ( ) ** 2 ) * usableHeight ;
1722
1721
circleY = randomVHeight + chartCeiling - circleR ;
1723
1722
}
1724
-
1723
+ // save the location of the new dot along with all the others
1725
1724
prevDotArray . push ( [ circleX , circleY ] ) ;
1726
1725
1727
1726
const circleElt = circle . cloneNode ( false ) ;
0 commit comments