add class / data-attribute to graphic dom node 4.x

813
2
05-01-2017 07:39 AM
BrandonFlessner
Occasional Contributor

I'm looking for a way to change the style of certain graphics based on user interaction. I have a bar chart in my application and when the user hovers over, for example, the 2015 bar, I want to highlight all the points on the map that occurred in 2015. I thought the best way to do this would be to add a data-year attribute to the graphic's dom node and use some CSS similar to Styling SVG with CSS | Guide | ArcGIS API for JavaScript 3.20.  But I see in Functionality matrix | ArcGIS API for JavaScript 4.3  that the dataAttributes method is "Not planned". Is there a way to do this at 4.x? 

Classes and CSS styling is used at 4.3 here: https://github.com/nickcam/FlareClusterLayer so it seems like it should be possible.

0 Kudos
2 Replies
RobertScheitlin__GISP
MVP Emeritus

Brandon,

   I would not go that route. You can just assign a year attribute to the graphics and then loop through the graphics to find those with attribute year equal to your desired value and then remove that graphic and add back to the GL using the different symbol.

BrandonFlessner
Occasional Contributor

Thanks for your reply Robert. I was hoping to use some CSS to add some animation and transition effects but your method is likely the best and easiest option for now.

0 Kudos