If it were regular TeX, using a package that allows plotting graphs might be the way to go. A quick search suggests TikZ, which also has a TikZJax js library to use as a substitute with MathJax. It might be a pain to set up though and not worth the effort if you will only be needing simple diagrams. For those you might be better off using basic inline svg. For example, this code