Hitachi Vantara Pentaho Community Forums
Results 1 to 10 of 10

Thread: Different colors for each bar in a Barchart (non-stacked single measure)

  1. #1

    Default Different colors for each bar in a Barchart (non-stacked single measure)

    Hi,

    It is possible to assign a color for each bar in a Barchart (non-stacked single measure)?

    For instance, if I want to create a chart which shows the total sales(Measure) by cities (Dimension), and I want every single city has a different color.

    I tried with the Pentaho Report Designer 3.7.0-GA without luck.

    The following images is an example of what I want to obtain:



    Any comment would be appreciated.

    Kind Regards

  2. #2

    Default

    Hi,

    Just give your Y-axis columnname that you bind in series-by-field property of chart.


    regards,
    Suganya

  3. #3

    Default

    Hi Suganya,

    Thank you very much for your reply.

    I've set the chart with the followings values:

    Name:  chart-settings.jpg
Views: 106
Size:  27.0 KB

    As it can be seen, I assigned the Categorical value to the series-by-field.

    The result is very close to what I expected but the bars are not centered over the x-ticks as you can see in the following screenshot:

    Name:  barchart_colors2.jpg
Views: 108
Size:  33.1 KB

    Now I'm using PRD 3.8

    Do I miss something?

    Any comments would be appreciated

    Kind Regards

  4. #4

    Default

    Hi Paul,

    Yes.. we have a property upper-margin and lower-margin..
    On Increasing lower margin, the bars will move to right.On Decreasing upper margin, the bars will move to left. 1.0 is 100%. so give values below 1 and check it up.


    Regards,
    Suganya

  5. #5

    Default

    Dear Suganya,

    Thanks again for your reply en for your time!

    I tried what you have suggested without success.

    I set the lower and upper margins to 1 and the bars disappear as it can be seen in the following screenshots:

    Name:  chart-settings3.jpg
Views: 106
Size:  17.3 KB Name:  barchart_colors4.jpg
Views: 107
Size:  33.1 KB

    Then, I played with some values and I realized that assigning values from 0 to 1 just move the whole set of bars to the left or to the right.

    As an example, I set both values to 0.25 and this is the result:

    Name:  chart-settings2.jpg
Views: 109
Size:  32.9 KB Name:  barchart_colors3.jpg
Views: 108
Size:  34.6 KB

    Once again, any comment would be (very) appreciated,

    Kind Regards,

  6. #6

    Default

    Hi Paul,

    Try giving 0.0090 as lower_margin;and upper_margin as 0.001 . also make your bar width (max_bar_width)to 0.2.
    category_margin property is used to set distance between 2 bars.

    Regards,
    Suganya

  7. #7

    Default

    Hi Suganya,

    I tried following your suggestions but no luck again

    Screenshots:

    Name:  chart-settings4.jpg
Views: 107
Size:  21.3 KB Name:  barchartColor5.jpg
Views: 107
Size:  21.8 KB

    I modified the suggested values and the only thing that changed is the distance between the origin and the first bar or the distance between the right margin and the last bar. I'm start to thinking that is a kind of bug because it is netiher a margin nor a distance between bars problem. If you look at the first two series (1,2) they are shown shifted on the left. Then series 3 and 4 are almost centerd, an finally series 5 and 6 are shifted to the right. It's something like the distance between ticks is not the same as the distance between bars and even worst, the initial value does not match.

    I'll keep on trying.

    Thanks again, Kind Regards

  8. #8

    Default

    HI Paul,


    Just try stacked property as "True" and specify only max-bar-width property alone as 0.2 0r 0.3 and try it out.
    Attaching sample screenshot below.

    Name:  Screenshot.png
Views: 103
Size:  13.0 KB


    Regards,
    Suganya

  9. #9

    Default

    Dear Suganya,

    Your help is priceless (more than master card )

    I followed your last comment and that made the trick. This is the final result:

    Name:  barchartColor6.jpg
Views: 104
Size:  36.6 KB

    Kind Regards,

  10. #10

    Default

    Cool Yar

    Regards,
    Suganya

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.