Using jqPlot plugins in PrimeFaces charts to draw lines on chart

你。 提交于 2019-12-04 06:34:02
BalusC

Your concrete problem is caused by incorrect ordering of JavaScript resources which should already be hinted by those JS errors complaining jQuery couldn't be found and incorrect <script> ordering in generated HTML output as you could see via rightclick View Source in webbrowser. Basically, you loaded the jqPlot script before jQuery and PrimeFaces scripts by misplacing the <h:outputScript> before <h:head>.

If you move the <h:outputScript> inside <h:body> with a target="head" like below ...

<h:head>
    <title>Chart</title>
</h:head>
<h:body>
    <h:outputScript library="jqplot-plugin" name="jqplot.canvasOverlay.min.js" target="head" />
    <h:outputScript library="js" name="extra_config.js" target="head" />

    <p:chart type="line" model="#{primeChart.lineModel1}" style="height:300px;" />
</h:body>

... then magic will start to work.

See also:


Unrelated to the concrete problem, library="js" is a bad practice. Carefully read What is the JSF resource library for and how should it be used? what exactly it means and how it should be used (quick answer: get rid of it and use name="js/extra_config.js").

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!