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

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

Class Method Summary collapse

Class Method Details

.mathjax_configObject



888
889
890
891
892
# File 'lib/charty/backends/plotly.rb', line 888

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

.prepareObject



857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
# File 'lib/charty/backends/plotly.rb', line 857

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



881
882
883
884
885
# File 'lib/charty/backends/plotly.rb', line 881

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