Module: Charty::Backends::Plotly::IRubyOutput

Defined in:
lib/charty/backends/plotly.rb

Class Method Summary collapse

Class Method Details

.mathjax_configObject



239
240
241
242
243
# File 'lib/charty/backends/plotly.rb', line 239

def self.mathjax_config
  <<~END
    if (window.MathJax) {MathJax.Hub.Config({SVG: {font: "STIX-Web"}});}
  END
end

.prepareObject



208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# File 'lib/charty/backends/plotly.rb', line 208

def self.prepare
  return if @prepared

  html = <<~HTML
    <script type="text/javascript">
      %{win_config}
      %{mathjax_config}
      require.config({
        paths: {
          plotly: "https://cdn.plot.ly/plotly-latest.min"
        }
      });
    </script>
  HTML

  html %= {
    win_config: window_plotly_config,
    mathjax_config: mathjax_config
  }

  IRuby.display(html, mime: "text/html")
  @prepared = true
end

.window_plotly_configObject



232
233
234
235
236
# File 'lib/charty/backends/plotly.rb', line 232

def self.window_plotly_config
  <<~END
    window.PlotlyConfig = {MathJaxConfig: 'local'};
  END
end