2013-04-27 73 views
0

如何在條形圖中顯示酒吧上的數據點?primefaces條形圖:在酒吧上顯示數據點

我不想使用數據提示或工具提示,只有當他們被矇蔽時纔會突出顯示數據點。

我想始終在欄上顯示數據點。

有沒有什麼正確的方法來得到它?

謝謝。

我想正是這樣

DataPoint on Bar

下面是我的代碼

<p:barChart id="barChartId" value="#{myBean.myModel}"    
     orientation="horizontal"    
     stacked="true" extender="ext" animate="true" shadow="false" />    
<h:outputScript>   
    function ext() { 
    this.cfg.highlighter = { 
      useAxesFormatters: false, 
      tooltipAxes: 'x' 
    };  
    this.cfg.legend = { 
      show: true, 
      location: 'ne', 
      placement: 'outside' 
    }; 
    this.cfg.seriesDefaults = { 
      pointLabels : { show: true }, 
    };    
    }   
</h:outputScript> 

這裏,熒光筆和傳說都工作正常,但點標籤不顯示在酒吧

+0

看到:HTTP:/ /stackoverflow.com/questions/12050008/primefaces-3-4-charts-datatipformat – 2013-04-27 12:26:00

+0

@NickHol:但我想在工具欄上的數據值不在工具提示 – swaps 2013-05-01 05:56:15

+0

你可以使用它來改變它,以便它始終顯示。 – 2013-05-01 07:24:03

回答

5

不當然,如果它會工作...

使用<p:barChartextender,就像這樣:

<p:barChart value="#{myBean.myModel}" widgetVar="myBarChart" extender="my_ext"/> 


<script type="text/javascript"> 
    function my_ext() { 
     this.cfg.seriesDefaults = { 
      renderer:$.jqplot.BarRenderer, 
      pointLabels: {show: true} 
     }; 
     this.cfg.stackSeries: true; 
    } 
</script> 

或本

<script type="text/javascript"> 
    function my_ext() { 
     this.cfg.seriesDefaults = { 
      pointLabels: {show: true} 
     }; 
     this.cfg.stackSeries: true; 
    } 
</script> 

而且看一看的jqplot例子:Bar charts

+0

我沒有拿到這個 – swaps 2013-05-01 07:21:17

+0

有一個錯字,現在試試... – Daniel 2013-05-01 07:22:28

+0

對不起,我不明白是什麼錯字 – swaps 2013-05-01 07:25:02

3

萬一人如果沒有按」通過標記答案的評論來爬行,因爲我原先並沒有這樣做。

該問題基本上不是pointLabels元素的配置,而是其原始狀態中的primefaces(從4.0開始)不包含所需的jqPlot插件。

因此實際上解決方案是使所需的插件jqplot.pointLabels.min.js可用。從bug跟蹤器(http://code.google.com/p/primefaces/issues/detail?id=5378)中的票證中提取出來,primefaces使用jqPlot版本1.0.8。

  • 下載jqplot 1.0.8從https://bitbucket.org/cleonello/jqplot/downloads/
  • 的插件添加到您的項目(例如,src/main/webapp/resources/jqplot-plugins
  • 插件的腳本添加到您的網頁(<h:outputScript library="jqplot-plugins" name="jqplot.pointLabels.min.js" />
+0

非常感謝。這真的很有幫助。 – vinay 2015-03-04 20:41:19

相關問題