Hitachi Vantara Pentaho Community Forums
Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Dynamic ranges on a dial

  1. #1

    Default Dynamic ranges on a dial

    Can someone point me to an example of how to put a range on a dial, dynamically in my xml file or help me with this?

    <interval>
    <label>under</label>
    <!-- this is the value that the range starts at -->
    <minimum>-15</minimum>
    <!-- this is the value that the range stops at -->
    <maximum>0</maximum>
    <!-- this is the color of the range -->
    <color>#ffffff</color>
    <!-- this is the color of the text for the range value and tick marks -->
    <text-color>#40bb40</text-color>
    <stroke-width>5</stroke-width>
    </interval>

    I'd like minimum and maximum to be determined via a query to my database and then used by the interval tag.

    Thanks
    Bob

  2. #2
    Join Date
    Dec 2005
    Posts
    531

    Default

    Hi Bob,

    this thread might help, it should explain how to dynamically change properties for the dial chart.

    http://forums.pentaho.org/showthread.php?t=54951

    Regards,
    Ingo

  3. #3

    Default

    Ingo,

    Here is my code in the .xaction file. Can you tell me why my dial isn't showing up, it has something to do with the intervals and me trying to dynamically set the lower and upper limits on the intervals.

    Thanks
    Bob

    <?xml version="1.0" encoding="UTF-8"?>
    <action-sequence>
    <title>Yearly Gross Sales DialChart</title>
    <version>1</version>
    <logging-level>DEBUG</logging-level>
    <documentation>
    <result-type>chart</result-type>
    <description>Dial Chart with the the current year sales</description>
    </documentation>
    <outputs>
    <image-tag type="string">
    <destinations>
    <response>content</response>
    </destinations>
    </image-tag>
    </outputs>
    <actions>
    <action-definition>
    <component-name>SQLLookupRule</component-name>
    <action-type>Relational</action-type>
    <action-outputs>
    <query-result type="result-set" mapping="query_result"/>
    </action-outputs>
    <component-definition>
    <jndi><![CDATA[myfirst]]></jndi>
    <live><![CDATA[false]]></live>
    <query><![CDATA[select ROUND(SUM(DBNTPRC)/1000000,2) as value, 0 as minimum, 12 as maximum
    from Dashboard_DBN_RAW
    where YEAR = 2007]]></query>
    </component-definition>
    </action-definition>
    <action-definition>
    <component-name>JavascriptRule</component-name>
    <action-type>JavaScript</action-type>
    <action-inputs>
    <query_result type="result-set"/>
    </action-inputs>
    <action-outputs>
    <salestot type="string"/>
    </action-outputs>
    <component-definition>
    <script><![CDATA[salestot = query_result.getValueAt(0,0);]]></script>
    </component-definition>
    </action-definition>
    <action-definition>
    <component-name>JavascriptRule</component-name>
    <action-type>JavaScript</action-type>
    <action-inputs>
    <query_result type="result-set"/>
    </action-inputs>
    <action-outputs>
    <minval type="string"/>
    </action-outputs>
    <component-definition>
    <script><![CDATA[minval = query_result.getValueAt(0,1);]]></script>
    </component-definition>
    </action-definition>
    <action-definition>
    <component-name>JavascriptRule</component-name>
    <action-type>JavaScript</action-type>
    <action-inputs>
    <query_result type="result-set"/>
    </action-inputs>
    <action-outputs>
    <maxval type="string"/>
    </action-outputs>
    <component-definition>
    <script><![CDATA[maxval = query_result.getValueAt(0,2);]]></script>
    </component-definition>
    </action-definition>
    <action-definition>
    <component-name>ChartComponent</component-name>
    <action-type>Dial Chart</action-type>
    <action-inputs>
    <chart-data type="result-set" mapping="query_result"/>
    <salestot type="string"/>
    </action-inputs>
    <action-outputs>
    <image-tag type="string"/>
    </action-outputs>
    <component-definition>
    <chart-attributes>
    <chart-type>DialChart</chart-type>
    <border-visible>true</border-visible>
    <tick-interval>1</tick-interval>
    <value-color>#9999bb</value-color>
    <tick-color>#808080</tick-color>
    <!-- this is the color of the needle -->
    <needle-color>#0000FF</needle-color>
    <plot-background-color>#FFFFFF</plot-background-color>
    <!-- intervals define ranges on the dial that are colored differently from the dial background -->
    <interval>
    <label>over</label>
    <!-- this is the value that the range starts at -->
    <minimum>{minval}</minimum>
    <!-- this is the value that the range stops at -->
    <maximum>{minval} + 3</maximum>
    <!-- this is the color of the range -->
    <color>#FF0000</color>
    <!-- this is the color of the text for the range value and tick marks -->
    <text-color>#bb4040</text-color>
    <stroke-width>2</stroke-width>
    </interval>
    <interval>
    <label>over</label>
    <minimum>{minval} + 3</minimum>
    <maximum>{minval} + 8</maximum>
    <color>#FFFF00</color>
    <text-color>#40bb40</text-color>
    <stroke-width>2</stroke-width>
    </interval>
    <interval>
    <label>over</label>
    <minimum>{maxval} - 4</minimum>
    <maximum>{maxval}</maximum>
    <color>#00FF00</color>
    <text-color>#40bb40</text-color>
    <stroke-width>2</stroke-width>
    </interval>
    </chart-attributes>
    <width><![CDATA[160]]></width>
    <height><![CDATA[160]]></height>
    <title>Current Year Sales ${salestot} Million </title>
    <by-row>true</by-row>
    </component-definition>
    </action-definition>
    </actions>
    </action-sequence>

  4. #4
    Join Date
    Dec 2005
    Posts
    531

    Default

    But you don't get any error, right?

    Try using one of the other output targets in:

    <action-outputs>
    <image-tag type="string"/>
    </action-outputs>

    Here you'll find some help regarding this topic: http://wiki.pentaho.org/display/Pent...hart+Component

    Regards,
    Ingo

  5. #5

    Default

    Quote Originally Posted by ingo.klose View Post
    But you don't get any error, right?

    Try using one of the other output targets in:

    <action-outputs>
    <image-tag type="string"/>
    </action-outputs>

    Here you'll find some help regarding this topic: http://wiki.pentaho.org/display/Pent...hart+Component

    Regards,
    Ingo
    No I don't get any errors. I've got my dial showing up correctly but the issue is that I'm trying to retrieve the minimum and maximum values from a result set and assign them to MinVal and MaxVal variables. Currently I retrieve a total sales value with no problem but when I try to retrieve the Min and Max values from that same result set that is when my dial doesn't appear. If I change my code for the salestot from

    <action-definition>
    <component-name>JavascriptRule</component-name>
    <action-type>JavaScript</action-type>
    <action-inputs>
    <query_result type="result-set"/>
    </action-inputs>
    <action-outputs>
    <salestot type="string"/>
    </action-outputs>
    <component-definition>
    <script><![CDATA[salestot = query_result.getValueAt(0,0);]]></script>
    </component-definition>
    </action-definition>

    to

    <action-definition>
    <component-name>JavascriptRule</component-name>
    <action-type>JavaScript</action-type>
    <action-inputs>
    <query_result type="result-set"/>
    </action-inputs>
    <action-outputs>
    <salestot type="string"/>
    </action-outputs>
    <component-definition>
    <script><![CDATA[salestot = query_result.getValueAt(0,1);]]></script>
    </component-definition>
    </action-definition>

    then I see my value of 0(minimum value based on my query) in the salestot value since I show it in the title. But the issue is that I can't get the Min and Max values into the appropriate values even though I'm doing the same thing I'm doing on the salestot variable.

    Thanks
    Bob
    Last edited by BobN; 10-26-2007 at 11:48 AM.

  6. #6
    Join Date
    Dec 2005
    Posts
    531

    Default

    Sorry about the confusion, I thought you got the dial running and had problems with the output.

    Well, I had a closer look and got it to work. There were two problems.

    1. You did not declare minval and maxval as input variables for the chart action
    2. You tried to do calculations on the minval and maxval parameters within the chart action. Any calculations should be done within the Javascript action.

    Here is a working example (note SQL statement and connection are different from yours)

    Regards,
    Ingo
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <action-sequence> 
      <title>Yearly Gross Sales DialChart</title>
      <version>1</version>
      <logging-level>DEBUG</logging-level>
      <documentation> 
        <result-type>chart</result-type>  
        <description>Dial Chart with the the current year sales</description> 
      </documentation>
    
      <inputs/>
    
      <outputs> 
        <image-tag type="string"> 
          <destinations> 
            <response>content</response> 
          </destinations> 
        </image-tag> 
      </outputs>
    
      <resources/>
      
      <actions> 
        <action-definition> 
          <component-name>SQLLookupRule</component-name>
          <action-type>Relational</action-type>
          <action-inputs/>
          <action-outputs> 
            <query-result type="result-set" mapping="query_result"/> 
          </action-outputs>
          <component-definition> 
            <jndi><![CDATA[SampleData]]></jndi>  
            <live><![CDATA[false]]></live>  
            <query><![CDATA[select ROUND((sum(variance)/ sum(budget))*100,2) as value, -15 as minimun, 15 as maximum
    from QUADRANT_ACTUALS]]></query> 
          </component-definition> 
        </action-definition>
      
        <action-definition> 
          <component-name>JavascriptRule</component-name>
          <action-type>JavaScript</action-type>
          <action-inputs> 
            <query_result type="result-set"/> 
          </action-inputs>
          <action-outputs> 
            <salestot type="string"/> 
          </action-outputs>
          <component-definition> 
            <script><![CDATA[salestot = query_result.getValueAt(0,0);]]></script> 
          </component-definition> 
        </action-definition>
      
        <action-definition> 
          <component-name>JavascriptRule</component-name>
          <action-type>JavaScript</action-type>
          <action-inputs> 
            <query_result type="result-set"/> 
          </action-inputs>
          <action-outputs> 
            <minval type="string"/> 
          </action-outputs>
          <component-definition> 
            <script><![CDATA[minval = query_result.getValueAt(0,1);]]></script> 
          </component-definition> 
        </action-definition>
      
        <action-definition> 
          <component-name>JavascriptRule</component-name>
          <action-type>JavaScript</action-type>
          <action-inputs> 
            <query_result type="result-set"/> 
          </action-inputs>
          <action-outputs> 
            <maxval type="string"/> 
          </action-outputs>
          <component-definition> 
            <script><![CDATA[maxval = query_result.getValueAt(0,2);]]></script> 
          </component-definition> 
        </action-definition>
      
        <action-definition> 
          <component-name>ChartComponent</component-name>
          <action-type>Dial Chart</action-type>
          <action-inputs> 
            <chart-data type="result-set" mapping="query_result"/>  
            <salestot type="string"/>  
            <minval type="string"/>  
            <maxval type="string"/> 
          </action-inputs>
          <action-outputs> 
            <image-tag type="string"/> 
          </action-outputs>
          <component-definition>
            <chart-attributes> 
              <chart-type>DialChart</chart-type>  
              <border-visible>true</border-visible>  
              <tick-interval>1</tick-interval>  
              <value-color>#9999bb</value-color>  
              <tick-color>#808080</tick-color>  
              <!-- this is the color of the needle -->  
              <needle-color>#0000FF</needle-color>  
              <plot-background-color>#FFFFFF</plot-background-color>  
              <!-- intervals define ranges on the dial that are colored differently from the dial background -->  
              <interval> 
                <label>over</label>  
                <!-- this is the value that the range starts at -->  
                <minimum>{minval}</minimum>  
                <!-- this is the value that the range stops at -->  
                <maximum>{maxval}</maximum>  
                <!-- this is the color of the range -->  
                <color>#FF0000</color>  
                <!-- this is the color of the text for the range value and tick marks -->  
                <text-color>#bb4040</text-color>  
                <stroke-width>2</stroke-width> 
              </interval>  
              <interval> 
                <label>over</label>  
                <minimum>{minval}</minimum>  
                <maximum>{minval}</maximum>  
                <color>#FFFF00</color>  
                <text-color>#40bb40</text-color>  
                <stroke-width>2</stroke-width> 
              </interval>  
              <interval> 
                <label>over</label>  
                <minimum>{maxval}</minimum>  
                <maximum>{maxval}</maximum>  
                <color>#00FF00</color>  
                <text-color>#40bb40</text-color>  
                <stroke-width>2</stroke-width> 
              </interval> 
            </chart-attributes>  
            <width><![CDATA[160]]></width>  
            <height><![CDATA[160]]></height>  
            <title>Current Year Sales ${salestot} Million</title>  
            <by-row>true</by-row>
          </component-definition> 
        </action-definition>
     
      </actions> 
    </action-sequence>
    Last edited by ingo.klose; 10-29-2007 at 10:13 AM.

  7. #7

    Default

    Ingo,

    Thanks for your help!

    Bob

  8. #8

    Default

    OK, so as I thought more about this and talked with people in the office I need to have my min and max values and range values from another table. So I created a new SQL Lookup action and a new Javascript action to retrieve the min/max values from this table. My issue comes up in the Chart action, how do I declare the 2 different action inputs one for my data and one for my range values (see bolded code below). So basically what I have is that I'm getting my main data from one table for the dial and the limits of the dial from another table. Again, my dial doesn't show up but I don't get any errors. I'm assuming I can't have two separate action inputs for a Chart action or if I can, then I did them the wrong way.

    Thanks
    Bob


    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <action-sequence>
      <title>Yearly Gross Sales DialChart</title>
      <version>1</version>
      <logging-level>DEBUG</logging-level>
      <documentation>
        <author>Bob</author>
        <result-type>chart</result-type>
        <description>Dial Chart with the the current year sales</description>
      </documentation>
      <outputs>
        <image-tag type="string">
          <destinations>
            <response>content</response>
          </destinations>
        </image-tag>
      </outputs>
      <actions>
        <action-definition>
          <component-name>SQLLookupRule</component-name>
          <action-type>Relational</action-type>
          <action-outputs>
            <query-result type="result-set" mapping="query_result"/>
          </action-outputs>
          <component-definition>
            <jndi><![CDATA[myfirst]]></jndi>
            <live><![CDATA[false]]></live>
            <query><![CDATA[select ROUND(SUM(DBNTPRC)/1000000,2) as value
                                from Dashboard_DBN_RAW
                                where YEAR = 2007]]></query>
          </component-definition>
        </action-definition>
        <action-definition>
          <component-name>JavascriptRule</component-name>
          <action-type>JavaScript</action-type>
          <action-inputs>
            <query_result type="result-set"/>
          </action-inputs>
          <action-outputs>
            <salestot type="string"/>
          </action-outputs>
      <component-definition>
            <script><![CDATA[salestot = query_result.getValueAt(0,0);]]></script>
          </component-definition>
        </action-definition>
        <action-definition>
          <component-name>SQLLookupRule</component-name>
          <action-type>Relational</action-type>
          <action-outputs>
            <query-result type="result-set" mapping="dial_limits"/>
          </action-outputs>
          <component-definition>
            <jndi><![CDATA[myfirst]]></jndi>
            <live><![CDATA[false]]></live>
            <query><![CDATA[select NumOfRanges, AbsMin, AbsMax,
             Range1Max, Range2Max, Range3Max, Range4Max
                                from Dial_Limits
            WHERE DialCode = "dial1"]]></query>
          </component-definition>
        </action-definition>
        <action-definition>
          <component-name>JavascriptRule</component-name>
          <action-type>JavaScript</action-type>
          <action-inputs>
            <dial_limits type="result-set"/>
          </action-inputs>
          <action-outputs>
            <minval type="string"/>
        <maxval type="string"/>
        <Range1Max type="string"/>
        <Range2Max type="string"/>
          </action-outputs>
      <component-definition>
            <script><![CDATA[minval = query_result.getValueAt(0,2);]]></script>
        <script><![CDATA[maxval = query_result.getValueAt(0,3);]]></script>
        <script><![CDATA[Range1Max = query_result.getValueAt(0,4);]]></script>
        <script><![CDATA[Range2Max = query_result.getValueAt(0,5);]]></script>
          </component-definition>
        </action-definition>
    
        <action-definition>
          <component-name>ChartComponent</component-name>
          <action-type>Dial Chart</action-type>
          <action-inputs>
            <chart-data type="result-set" mapping="query_result"/>
            <salestot type="string"/>
          </action-inputs>
      <action-inputs>
            <chart-data type="result-set" mapping="dial_limits"/>
            <minval type="string"/>
        <maxval type="string"/>
        <Range1Max type="string"/>
        <Range2Max type="string"/>
          </action-inputs>
          <action-outputs>
            <image-tag type="string"/>
          </action-outputs>
          <component-definition>
            <chart-attributes>
              <chart-type>DialChart</chart-type>
              <border-visible>true</border-visible>
              <tick-interval>1</tick-interval>
              <value-color>#9999bb</value-color>
              <tick-color>#808080</tick-color>
              <!--  this is the color of the needle -->
              <needle-color>#0000FF</needle-color>
              <plot-background-color>#FFFFFF</plot-background-color>
              <!--  intervals define ranges on the dial that are colored differently from the dial background -->
              <interval>
                <label>over</label>
                <!-- this is the value that the range starts at -->
                <minimum>{minval}</minimum>
                <!-- this is the value that the range stops at -->
                <maximum>{Range1Max}</maximum>
                <!--  this is the color of the range -->
                <color>#FF0000</color>
                <!--  this is the color of the text for the range value and tick marks -->
                <text-color>#bb4040</text-color>
                <stroke-width>2</stroke-width>
              </interval>
              <interval>
                <label>over</label>
                <minimum>{Range1Max}</minimum>
                <maximum>{Range2Max}</maximum>
                <color>#FFFF00</color>
                <text-color>#40bb40</text-color>
                <stroke-width>2</stroke-width>
              </interval>
              <interval>
                <label>over</label>
                <minimum>{Range2Max}</minimum>
                <maximum>{maxval}</maximum>
                <color>#00FF00</color>
                <text-color>#40bb40</text-color>
                <stroke-width>2</stroke-width>
              </interval>
            </chart-attributes>
            <width><![CDATA[160]]></width>
            <height><![CDATA[160]]></height>
            <title>Current Year Sales ${salestot} Million</title>
            <by-row>true</by-row>
          </component-definition>
        </action-definition>
      </actions>
    </action-sequence>

  9. #9
    Join Date
    Dec 2005
    Posts
    531

    Default

    Hi Bob,

    on the first look I found a couple of issues:

    1.2. Java Script:

    Code:
    <action-definition>
          <component-name>JavascriptRule</component-name>
          <action-type>JavaScript</action-type>
          <action-inputs>
            <dial_limits type="result-set"/>
          </action-inputs>
          <action-outputs>
            <minval type="string"/>
        <maxval type="string"/>
        <Range1Max type="string"/>
        <Range2Max type="string"/>
          </action-outputs>
      <component-definition>
            <script><![CDATA[minval = query_result.getValueAt(0,2);]]></script>
        <script><![CDATA[maxval = query_result.getValueAt(0,3);]]></script>
        <script><![CDATA[Range1Max = query_result.getValueAt(0,4);]]></script>
        <script><![CDATA[Range2Max = query_result.getValueAt(0,5);]]></script>
          </component-definition>
        </action-definition>
    should be


    Code:
    <action-definition>
          <component-name>JavascriptRule</component-name>
          <action-type>JavaScript</action-type>
          <action-inputs>
            <dial_limits type="result-set"/>
          </action-inputs>
          <action-outputs>
            <minval type="string"/>
        <maxval type="string"/>
        <Range1Max type="string"/>
        <Range2Max type="string"/>
          </action-outputs>
      <component-definition>
            <script><![CDATA[minval = query_result.getValueAt(0,2);
    maxval = query_result.getValueAt(0,3);
    Range1Max = query_result.getValueAt(0,4);
    Range2Max = query_result.getValueAt(0,5);]]></script>
          </component-definition>
        </action-definition>
    2. Action Inputs (only one action-inputs tag) for chart should be:

    Code:
    <action-inputs>
        <salestot type="string"/>
        <minval type="string"/>
        <maxval type="string"/>
        <Range1Max type="string"/>
        <Range2Max type="string"/>
    </action-inputs>
    Hope this helps!

    Regards

  10. #10

    Default

    Hi Ingo,

    First off thanks for all your help!

    So I made the changes you told me to try in regards to the CDATA (I didn't realize I could put multiple lines of code in one CDATA statement). 2nd with the changes to the action input as shown below...what happened to the <chart-data type="result-set" mapping="query_result"/> or is it not needed. If it is needed I'd need one for the result set that produces the Min/Max and range values too, correct? Would it be a 2nd <chart-data...> node within the action-inputs? Because that is what I have now but the dial still doesn't show up.

    Code:
    <action-inputs>
        <salestot type="string"/>
        <minval type="string"/>
        <maxval type="string"/>
        <Range1Max type="string"/>
        <Range2Max type="string"/>
    </action-inputs>
    Here's what I have....
    Code:
     <action-inputs>
            <chart-data type="result-set" mapping="query_result"/>
            <salestot type="string"/>
            <chart-data type="result-set" mapping="dial_limits"/>
            <minval type="string"/>
        <maxval type="string"/>
        <Range1Max type="string"/>
        <Range2Max type="string"/>
          </action-inputs>
    Thanks
    Bob

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 - 2017 Pentaho Corporation. All Rights Reserved.