Splunk Search

How to change charting.fieldColors through JS of already rendered chart?

seva98
Path Finder

Hi, does anyone know how can I change fieldColors after chart was rendered?

Thing is that we have two different visualizations and I need to sync colors when both are ready. I am able to read colors from the second vizualtion but setting it through following commands doesn't work even when I hide/show and/or render the chart when setting colors.

var chartview = mvc.Components.get("chartid");
// didn't work
chartview.settings.set("charting.fieldColors",'{"sth":0x65a637}');
// also didn't work
chartview.options["charting.fieldColors"]='{"sth":0x65a637}';
0 Karma

niketn
Legend

@seva98 what are the queries in the two visualizations you are using? What are the visualizations? Also how is the color being applied in the second chart are you using charting.fieldColors or charting.seriesColors? If charting.fieldColors is being applied, why can't same be applied to the first chart?

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

seva98
Path Finder

@niketnilay I am not able to share code from the project as it is private but I will share some mock code that is very similar. I am able to retrieve data from the first custom visualization in following format:

var colorCollection = {
"a": "0xff7f0e",
"b": "0xeb5faa",
"c": "0xff3f0e"
}

And I need to set this color colletion to corresponding "a", "b" and "c" areas in area chart. The custom visualziation takes longer time to load so I have to update area chart after custom visualization has been loaded.

This code was used to change colors but it doesn't work now:

var vizualization = mvc.Components.get("vizualization_area_chart");
vizualization.getVisualization(function(chartView) {
            chartView.settings.set({ "charting.fieldColors": stringifyCollection(colorsCollection) });
        });
0 Karma
Get Updates on the Splunk Community!

Enterprise Security Content Update (ESCU) | New Releases

In December, the Splunk Threat Research Team had 1 release of new security content via the Enterprise Security ...

Why am I not seeing the finding in Splunk Enterprise Security Analyst Queue?

(This is the first of a series of 2 blogs). Splunk Enterprise Security is a fantastic tool that offers robust ...

Index This | What are the 12 Days of Splunk-mas?

December 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...