How do I create a custom colour palette script.

Creating a custom colour palette


To create a new colour palette, start with the following script layout:

api.register({
    type: "palette",
    name: "Palette Name",
    items: [
        
    ]
});


After 'items' enter an array (a comma separated list within square brackets) of your chosen colours in hexadecimal format e.g. "#d62728".

e.g.

api.register({
    type: "palette",
    name: "NHS Colours",
    items: [
		[
                "#1f77b4",
		"#ff7f0e",
		"#2ca02c",
		"#d62728",
		"#9467bd",
		"#8c564b",
		"#e377c2",
		"#7f7f7f",
		"#bcbd22"
                 ]	 
    ]
});

(To convert colour codes from RGB into HEX you can use a website translator e.g. http://www.convertacolor.com/.)


If you want to add multiple variations of a colour scheme (e.g. NHS 6 colours, 10 colours, 14 colours), simply add multiple arrays to items:

api.register({
    type: "palette",
    name: "NHS Colours",
    items: [
		[	
		"#1f77b4",
		"#ff7f0e",
		"#2ca02c",
		],
		[
		"#d62728",
		"#9467bd",
		"#8c564b",
		"#e377c2",
		"#7f7f7f",
		"#bcbd22",
		]
	 
    ]
});

 


This generates one palette per colour array. By default, these are named in OrgVue as “Palette Name {length of colour array}” – e.g., using the above example, “NHS Colours 3” and “NHS Colours 6”.

Alternatively, you could extract the OrgVue default colour palette script and adapt this to your needs. See how to do that here.

Once you have finalised your script you are now ready to register it so that becomes either a dataset specific palette, or whether it is available for the whole tenant.

Have more questions? Submit a request

Comments