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

issues having 2 bar charts in multi axis chart


user4jas

Recommended Posts

1. Hello All - With 3 columns "At time" ,"customers out of power","customers restored of power" ,I have 2 bar charts in a multi  axis chart (placed in the summary band). Details of chart are:

Chart 1. Chart data  -series expression  (Static value)"customers restored ", (Bar color green)

                                     category expn : column "At Time" ,

                                     value expn : column : "customers restored of power"

Chart 2 . Chart data  -series expression  (Static value)"customers out ", (Bar color Red)

                                     category expn : column :"At Time" ,

                                     value expn : Column : "customers out of power "

Isuues : since they have the same Category Expression .The Bar overlaps one another  for the same time block and it seems like the parent chart takes precedence .

At a given time:

i.e 1. if  cust restored bar green bar value > cust out bar (red) bar value ,it hides the red bar

      2. If cust restored bar(green)value< cust out ,it shows the lesser green projection on  the bigger red bar .

So here i would want to know if .  1.There is a way to offset any one bar  to display the two bars side by side to each other. If there is .Please let me know the code. Thank you

 

 

Link to comment
Share on other sites

  • 2 weeks later...
  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

  • 1 year later...

Hi,

I'm currently facing the same problem. The difference is, that my two bar charts have different value types.

 

Chart 1. Chart data -series expression "Number of clicks"

category expn : column "Week of Year"

value expn : column : "Clicks" <= quantity e.g. 200
 

Chart 2 . Chart data -series expression  "Costs"

category expn : column :"Week of Year"

value expn : Column : "Costs"   <= currency  e.g. "1.123,00 €"

 

Therefore I do need two different value axis. The two bars should be placed next to each other (with a small spacing) and should not overlap. 

 

Any suggestions?



Post Edited by drizzt21 at 08/26/2011 11:55
Link to comment
Share on other sites

  • 1 year later...
  • 3 years later...

It's a bit late but maybe this helps someone in the future.

I managed to solve this exact same problem by adding empty series and using a chart customizer.

My category series look like this:

                                <categorySeries>                                    <seriesExpression><![CDATA["sales"]]></seriesExpression>                                    <categoryExpression><![CDATA[$F{REGION}]]></categoryExpression>                                    <valueExpression><![CDATA[$F{RES}]]></valueExpression>                                </categorySeries>                                <categorySeries>                                    <seriesExpression><![CDATA[""]]></seriesExpression>                                    <categoryExpression><![CDATA[$F{REGION}]]></categoryExpression>                                    <valueExpression><![CDATA[0]]></valueExpression>                                </categorySeries>[/code]

 

                                <categorySeries>                                    <seriesExpression><![CDATA[""]]></seriesExpression>                                    <categoryExpression><![CDATA[$F{REGION}]]></categoryExpression>                                    <valueExpression><![CDATA[0]]></valueExpression>                                </categorySeries>                                <categorySeries>                                    <seriesExpression><![CDATA["orders"]]></seriesExpression>                                    <categoryExpression><![CDATA[$F{REGION}]]></categoryExpression>                                    <valueExpression><![CDATA[$F{SUMA}]]></valueExpression>                                </categorySeries>[/code]

In each one of the multiaxis' axis.

Then with a Chart customizer setted on the multiaxis:

public class BarChartSeparator implements JRChartCustomizer {    @Override    public void customize(JFreeChart chart, JRChart jasperChart) {        // TODO Auto-generated method stub        chart.getCategoryPlot().getRenderer(0).setSeriesVisibleInLegend(1, false);        chart.getCategoryPlot().getRenderer(1).setSeriesVisibleInLegend(0, false);           }}[/code]

It may not be the most elegant solution posible, but it does the job.
 

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...