Hitachi Vantara Pentaho Community Forums
Results 1 to 4 of 4

Thread: Trying to change marker color based on data value

  1. #1
    Join Date
    Jun 2007
    Posts
    103

    Lightbulb Trying to change marker color based on data value

    Hello - Perhaps you can help me with this... I'm trying to color the map markers based on the value of a data column, I've called it fill.
    See the attached zip file with my CDA/CDE/CDFDE - everything is self-contained, data is being returned from a scriptable component.
    There are three possible values for "fill" and I'd like a different color for each. Can someone look at what I put together and say where I've gone wrong?

    Thanks in advance for any assistance!
    - Russell
    Attached Files Attached Files

  2. #2

    Default

    I never do that. Perhaps you can get help from this thread.
    https://forums.pentaho.com/showthrea...ing-openstreet
    I hope
    Luciano

  3. #3
    Join Date
    Jun 2007
    Posts
    103

    Default

    Thank you, Luciano, I appreciate the link.

    I found the answer - here are the details:

    The answer is that in the PreExecution code we need to identify the column to be used to drive the color. It's called the fill column. This code does that:
    // Specify the column to be used for the fill value - the third one
    // which is numBikes. Remember zero-based counting.
    this.visualRoles = {
    fill: 2
    };


    // Get the value of the "fill" column (injuryCode) and color code based on it
    this.attributeMapping.fill = function(context, seriesRoot, mapping, row) {
    var value = row[ mapping.fill];


    if (_.isNumber(value)) {
    if( value == 1) { return "yellow"; }
    else if( value == 2) { return "blue"; }
    else return "red";
    }
    };

    The visualRoles specifies which column maps to the fill column, in my case it's column 2. Once the map component has that, we can check for the value and set the color appropriately. Strictly speaking, because I named the column fill I don't need to specify the visualRoles - however in my updated version I named the column numBikes, which is more reflective of what it is, and then I do need to specify that column as the fill.

    - rlm

  4. #4

    Default

    I'm glad that helped

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.