Visokio website     Downloads     Video tutorials     KnowledgeBase  
Content View: Scripting - Array of colours? - Visokio Forums
Content View: Scripting - Array of colours?
  •     Bart March 13, 2014 8:50AM
    Hi,

    Is there a way to get all colours assigned to the field into array inside content view?

    Bart
  • 3 Comments
  •     michael March 14, 2014 6:17AM
    Hi Bart,

    Could you describe in more details and possibly give an example of what you are trying to achieve.

    If you want an array of colours:

    var arr = ["#ff0000", "#00ff00"];

    or

    var arr = [];
    for (var i = 0; i < 10; i++) {
    arr.push("#ff0000");
    }


    etc..

    If you want to generate colours from values, use to hex:

    var red = "#"+(222).toString(16)+"0000";

    or (new Number(222)).toString(16)
  •     michael March 14, 2014 6:36AM
    Hi Bart,

    If you need to use "Country" field "Colours" in calculations, you need to make those colours available in data-set some how.

    The best way so far (as we don't propagate colour keys to calculations so far..) would be to create a source .CSV file with colour mapping:
    "Country", "Colour".


    Use this colour mapping file in your "DataManager" so in each row for each "Country" you will have correspondent "Country Colour" field.

    Then you just need to use the value from this field.

    Then you'll need to synchronize this file and your ColourKey configuration for this Field. Though it is some extra work but it is better than hardcore colour mapping in Script.
  •     Bart March 14, 2014 6:40AM
    It is still not ideal as in the future we might have more countries or if it comes to other fields more values and then I would need to add them to csv every time they come. I am looking for a solution which will be fully automated and will always work, regardless of number of values in the field.

Welcome!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Apply for Membership