Jump to content
We've recently updated our Privacy Statement, available here ×

Is it possible to display values above bar chart ?


veeresh.jayakumar

Recommended Posts

i have created a barchart using the ad-hoc view in jasperReport_server .Currently the values display only when i hover the mouse over the barchart .i was wondering is it possible to display the value above the barchart at all times using jasperReport_server. i am new to this thing i really need an answer from the experts down here 

thanks to all in advance

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

Yes, that's is posibble but you have to make couple of modifaction on some js file. 

First you need t change what scripts are used by jasperserver. Default is "optimized_scripts". You have to change it to "scripts"

          Open 'WEB-INFjs.config.properties' with a text editor and change 'javascript.optimize=true' to false. (needs restart application server after modification)

Second, open datamapper js file (scriptsbower_componentsbi-reportsrcadhoccharthighchartsDataMapper.js) and find 'getCommonSeriesGeneralOptions' method.

Add the bold part to that method and save it.

 

      getCommonSeriesGeneralOptions: function(extraOptions) {
            var doAxisSwap = HDM.doAxisSwap(extraOptions.chartState.chartType);
 
            var options = _.extend(HDM.getGeneralOptions(extraOptions), {
                xAxis: HDM.getXAxisOptions(doAxisSwap, extraOptions),
                yAxis: HDM.isDualOrMultiAxisChart(extraOptions.chartState.chartType) ? [] :
                    HDM.getYAxisOptions(doAxisSwap, extraOptions),
                plotOptions: {
                    series: {
                        marker: {
                            enabled: extraOptions.chartState.showDataPoints
                        },
                        dataLabels: {
                                               enabled: true,
                                               formatter: function () {
                                                                   return Highcharts.numberFormat(this.y,2); //decimal point
                                               }
                        },
 
                        tooltip: {
                            dateTimeLabelFormats: extraOptions.isTimeSeries ?
                                HDM.getDateTimeLabelFormats(extraOptions.chartState.timeSeriesCategorizerName) : undefined,
                            xDateFormat: extraOptions.isTimeSeries ?
                                HDM.getDateTimeTooltipFormats(extraOptions.chartState.timeSeriesCategorizerName) : undefined
                        }
                    }
                },
                series: [],
                legend: HDM.getLegendOptions(extraOptions)
            });
 
            if (HDM._isTooltipFollowPointerEnabled(extraOptions.chartState.chartType)) {
                options.tooltip.followPointer = true;
            }
 
            if (HDM.isDualOrMultiAxisChart(extraOptions.chartState.chartType) || HDM.isSpiderChart(extraOptions.chartState.chartType)) {
                options.tooltip.shared = true;
            } else {
                options.tooltip.shared = false;
            }
 
            return options;
        },
 
After modifications clear your browser cache and open an adhoc chart. You should see the datalabels if everything is OK :)

datalabels_adhoc.png.ada4870a4c822c3dd22ff6777402301a.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...