Hitachi Vantara Pentaho Community Forums
Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: Bar chart colors dynamically changed based on data value. Along with JavaScript vars

  1. #11

    Default

    Another question, this is kinda a more in depth usecase for this scenario.

    So I can now return different colors based on the data values, but I just learned that sometimes these are not standard across the board. For instance the bars may have different cuttoffs.

    Bar 1: green = 0-2, yellow = 2.1-4, red = 4.1-6.0
    Bar 2: green = 0-1.5, yellow = 1.6-3.8 red = 3.9-6.0
    Bar 3: green = 6.0-4.0, yellow = 3.9-2.0, green = 1.9-0

    I feel like this would be easy for me to do if I could get the xaxis label for each bar, and than based on the name I would know how to evaluate the data. The problem is that I cannot for the life of me find the variable that would contain these labels. Any ideas?

  2. #12
    Join Date
    Jul 2007
    Posts
    2,497

    Default

    That's in something like this.scene.series
    Pedro Alves
    Meet us on ##pentaho, a FreeNode irc channel

  3. #13

    Default

    thanks for the direction, but am I missing something totally obvious? I am fairly new to Pentaho and saying something like "this.scene.series" means absolutely nothing to me at this point mostly because I dont know where to go from there. Is there any documentation where I could find more information about what this.scene.series contains? Its attributes and stuff, sort of like a javadocs. I feel like many people on this forum know a bunch of different variables to play around with in these things and I am always just lost with them.

  4. #14
    Join Date
    Mar 2012
    Posts
    645

    Default

    Hi,

    you can find some information about the scene structure here.

    Generally, when executing code in an extension point, you have a "scene" argument, that is the same as «this.scene».

    The scene contains a map of variables, named "vars", so you write «this.scene.vars».

    Variables are generally named after the visual roles of each chart type, so you'll have a "series" variable, a "category" variable, a "value" variable, for a typical categorical chart.

    A variable is itself an object cause you have, at the minimum, the variable's "value" and the variable's "label".

    So, summing it all up, for accessing the series value in an extension point, you write: «this.scene.vars.series.value».

    We're working on some sugar functions, accessible from «this» to make your and our wrists type less.

    Edit 2013-10-23: Added to master of CDF and CGG new sugar methods for this end.

    You can now use the following, from the pvc.visual.Context or the pvc.visual.Scene, to obtain the value of scene variables:

    • most charts (except, notably, the Pie chart): getSeries()
    • categorical charts: getCategory()
    • categorical charts and the legend scenes: getValue()
    • metric charts: getX(), getY()
    • cartesian axes panel scenes: getTick()


    There are also getSeriesLabel(), getCategoryLabel(), etc., versions of all these.

    For those variables/visual-roles for which no sugar method exist, or if you prefer/need a more dynamic approach, the new "get" method can be used as in the following example:
    • get("category") <=> getCategory()
    • get("category", "label") <=> getCategoryLabel()
    Last edited by duarte.leao; 04-10-2014 at 01:56 PM.

  5. #15

    Default

    Thanks, this post has been extremely helpful and I was able to get it to work using the vars.category.label. Thanks again!

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.