Open malramsay64 opened 6 years ago
I agree that it would be nice to support this, and it is certainly easier to achieve than general LaTeX support. However, this would still require custom support, changing Vega's text mark from a single string that can be drawn with one rendering call (or SVG element) to a multi-component setup involving alternative text baselines, appropriate spacing calculation, and also bounds calculation across the various parts. Plus, we'd need to determine an appropriate syntax with suitable escaping (e.g., to render text that would otherwise indicate super or sub-script).
This feature is not part of our current planning. That said, if someone is potentially interested in implementing this, I'm happy to help discuss and provide guidance. A good starting point would be to familiarize oneself with the text mark handling in vega-scenegraph: https://github.com/vega/vega-scenegraph/blob/master/src/marks/text.js
To define certain text as super- and subscript in the vega
specification might be nice indeed, but there is already a certain support for super and subscript, which might be sufficient for your need. I made this spec a while ago and it shows the capability of super and subscript
I investigated whether it was possible to incorporate JsonML notation of svg tspan, which is WaveDrom's approach, in the title and text of vega.
In WaveDrom, rich text using tspan can be embedded in the header and footer.
https://observablehq.com/@drom/wavedrom
WaveDrom seems to use packages called tspan and onml for this process, so I created a demo.
I agree with the use of MathJax or KaTex as suggested by #898.
The reason for presenting comments and demos was because I was interested in the question: “What json format is better for math notation?”
The answer I derived from the demo is that inline html particles should not be used for security, and svg's jsonML is not good.
While complete support for LaTeX text in #898 is difficult to implement, I was wondering if support for just super/sub scripted characters is simpler to implement. Many of the characters required for mathematical expression are available through Unicode characters, except for super and subscript characters which don't even cover the lowercase latin alphabet.
I am primarily interested if there might be an alternate (simpler) method of implementing this that doesn't involve LaTeX.