Jump to content
JasperReports 7.0 is now available ×


  • Posts

  • Joined

  • Last visited

jed.allen's Achievements


Newbie (1/14)

  • Week One Done
  • One Month Later
  • One Year In
  • First Post Rare
  • Conversation Starter Rare

Recent Badges



  1. So this took me a while to figure out so I thought I'd share my solution here in case anyone else runs into this problem. Situation: I have a multi axis chart, ColumnLine, with two yAxis metrics. The xAxis is a monthly scale in the form MMM-YY for a period of 13 months starting with "last month". The two yAxis measures are "number of visitors" to a website, and "amount saved" by those visitors. Both of these values are being reported to Google Universal Analytics as Page Hit data and a Custom Dimension, respectively. (I wrote a custom Data Adapter that connects to Google UA and performs a RESTful query to get this data back out, but that is not in the scope of this article). We are using Jaspersoft Server 6.0.0 running on Amazon Web Services. My issue arose when our marketing department insisted that the "money saved" measure be the bar in the graph, and the "number of visitors" be the line in the graph, and the scale for "visits" be on the left and "money saved" on the right. When the chart was created in Jaspersoft Studio, it automagically put the "money saved" on the left and "visits" on the right. What I want to do is similar to the functionality presented here, but done through Studio. Here is the solution to swap them: Right click the chart in the "design" tab of Jaspersoft Studio and select "Edit Chart Properties"Click the "Show Advanced Properties" buttonClick "add"Make sure the "Use an expression" box is uncheckedFor property name, put "yAxis.opposite" (without quotes)For Property Value put "true" (without quotes)Click okNow, if you were to preview your chart, you would see that both of the yAxis scales are on the right hand side. This is because Studio tries to be clever and will automatically put the second measure on the right hand side, in the background. Overriding this behavior is a bit tricky, because in at the properties level you cannot access the second yAxis properties in the way you would hope. (i.e., setting a yAxis[1].opposite property or something) My solution was to do the following to get the secondary yAxis over to the left: Edit the WEB-INFclassesjasperreports.properties file and add the following line, and restart the server:This directory resides in /usr/share/tomcat7/webapps/jasperserver-pro on AWS for me, but may vary based on your installationGo back to Jaspersoft Sudio, go to Show Advanced Properties for your chart, and add the following property:Property name: chart.events.loadProperty value: function(event) {this.yAxis[1].update({opposite: false});}This will cause the chart to render with both yAxis on the right, but then use a JSON call to modify the chart properties after loading to move the secondary yAxis from the right to the left of the chart.You can use this method to dynamically change any aspect of the chart after rendering, in case your problem is a little different than mine.I hope that helps someone. Good luck!
  2. Put your seconds value in the chart as the measure, and then add the following property on the "show advanced properties" tab. property: yAxis.labels.formatter value: function() { return parseInt(this.value/3600) + ":" + (parseInt((this.value % 3600) / 60)) + ":" + this.value % 60} and if you want leading zeroes for minutes and seconds, you can try: value: function() { return parseInt(this.value/3600) + ":" + ("0" + parseInt((this.value % 3600) / 60)).slice(-2) + ":" + ("0" + this.value % 60).slice(-2) }
  • Create New...