2014-09-02 71 views
0

我想在Flot的軸標籤中渲染LaTeX。它的工作原理,因爲這是在我的頭執行這個page第一經過:MathJax在Flot的軸標籤中

<script type="text/x-mathjax-config"> 
    MathJax.Hub.Config({ 
    tex2jax: {inlineMath: [["$", "$"], ["\\(", "\\)"]]} 
    }); 
</script> 
<script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> 

但是,用戶必須輸入缺省值以外的新的參數,並通過<input type="button" value="Evaluate" onclick="discrete()">執行JS的選項。這是一個在這一點上,MathJax無法「看到」發生了什麼事在discrete.js末:

MathJax.Hub.Config({//needed? 
    tex2jax: {inlineMath: [["$", "$"], ["\\(", "\\)"]]} 
}); 
function doPlot(position) {//Flot 
    $.plot("#placeholder", [//data 
    { data: z_m_plot } 
    ],//options 
    { 
     series: { 
     points: { 
      radius: 3, 
      show: true, 
      fill: true, 
      fillColor: "navy" 
     }, 
     color: "navy" 
     }, 
     xaxis: { axisLabel: "$z_{max}(j - 1)$" }, 
     yaxis: { axisLabel: "$z_{max}(j)$" } 
    } 
    ); 
} 
doPlot("left"); 

有沒有辦法通過各個字符串MathJax以呈現軸標籤$z_{max}(j - 1)$$z_{max}(j)$

+1

注:cdn.mathjax.org接近其結束生命,檢查https://www.mathjax.org/遷移技巧的cdn-shut-down(也許更新您的答案爲未來的讀者)。 – 2017-04-21 07:18:06

回答

1

MathJax在頁面加載時運行並轉換數學標記。如果你想讓它再運行你重繪的情節add this後:從未來

doPlot("left"); 
MathJax.Hub.Queue(["Typeset",MathJax.Hub]); // queue up MathJax