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

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

Class Method Summary collapse

Class Method Details

.mathjax_configObject



622
623
624
625
626
# File 'lib/charty/backends/plotly.rb', line 622

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

.prepareObject



591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
# File 'lib/charty/backends/plotly.rb', line 591

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



615
616
617
618
619
# File 'lib/charty/backends/plotly.rb', line 615

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