The easy option is to just put a white background behind the diagrams. It might not be as pretty as having the image designed right for a black background but its better than that hack.
Which is better you can compare
Here's before dark mode
https://codepen.io/greggman/full/vYYOxjd
Here's leaving the backgrounds to the diagrams white
https://codepen.io/greggman/full/zYYGZWB
And here's the hue rotated solution
https://codepen.io/greggman/full/abbOJYB
The ideal solution would be to make all the diagrams twice but that's a ton of work if your site has lots of diagrams. Of course it's all an opinion. I don't have time to redo all the diagrams or go make them CSS styled indivdually so this is the solution I chose for now.