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

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

Class Method Summary collapse

Class Method Details

.mathjax_configObject



914
915
916
917
918
# File 'lib/charty/backends/plotly.rb', line 914

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

.prepareObject



883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
# File 'lib/charty/backends/plotly.rb', line 883

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



907
908
909
910
911
# File 'lib/charty/backends/plotly.rb', line 907

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