BarChart custom Point Labels throw exception in JS

UI Components for JSF
Post Reply
Selir
Posts: 1
Joined: 19 Nov 2016, 10:32

19 Nov 2016, 11:02

Hi,

I wanted to render custom Point labels for my bar chart. There's no API in BarChartModel for that, so I used extender function in JS:

Code: Select all

<script>
            function barExt() {     
                this.cfg.series = [
                    {pointLabels:{
                       show: true,
                       labels: #{summaryBean.barDataLabels}
                     }}];
</script>
After evaluating barDataLabels, this line looks like this:

Code: Select all

labels: ['8052 kg', '180 kg', '300 kg']
The problem is that only first serie is ever shown because there's error thrown in JS:

Code: Select all

TypeError: D[w] is undefined      charts.js.xhtml:1:322399
It works if using pure jqPlot (sample taken from jqplot site, embedded directly in my page):

Code: Select all

<script>
            $(document).ready(function(){
                var line1 = [14, 32, 41];
                var plot3 = $.jqplot('chart3', [line1], {
                  title: 'Bar Chart with Point Labels', 
                  seriesDefaults: {renderer: $.jqplot.BarRenderer},
                  series:[
                   {pointLabels:{
                      show: true,
                      labels:#{summaryBean.barDataLabels}
                    }}]
                });
            });
</script>
<div id="chart3"></div>
I've used extender for pie chart for labels and it worked fine (although other settings were changed).
One "workaround" for that it to just use pure jqplot and feed it with data from bean as shown, but that would require some changes in underlying bean which I'd like to avoid.

Do you have any idea how to achieve custom point labels for bar chart?

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 30 guests