Alison Posted May 29, 2020 Report Share Posted May 29, 2020 Hi, Hi can I change the color of the column in chart for the blank values. For example, I want the color of the first column (blank) to be color red Leon13 1 Quote Link to comment Share on other sites More sharing options...
Hastur Posted May 29, 2020 Report Share Posted May 29, 2020 Hello! To change the color you need to use additional JS code. It will parse the data in chart and change the color according to name of the column. Here is the code: <script type="text/javascript"> document.addEventListener('DataPageReady', chartUpdateHandler); function chartUpdateHandler(event) { var cleaner = function(interv) { clearInterval(interv); } let interv = setInterval(() => { if (!!Highcharts) { const options = Highcharts.charts[0].series[0].data; let data = []; options.forEach(option => { let localData = {}; localData.y = option.y; localData.name = option.name; if(option.name === "(blank)") { localData.color = '#ee5921'; } else { localData.color = '#3186AD'; } data.push(localData); }) Highcharts.charts[0].update({ series: { data: data } }); cleaner(interv); } }, 200); } </script> You need to insert this code into the Header of the report DataPage. Do not forget to disable the HTML editor. Alison 1 Quote Link to comment Share on other sites More sharing options...
SinJunYoung Posted May 29, 2020 Report Share Posted May 29, 2020 Hello, you can also try getting the nth child but will be a static change of color display. But since the chart will always return the blank in the first line, we can always modify the 1st one to be set as orange. Try pasting this to the header as well: <style> rect.highcharts-point.highcharts-color-0:nth-child(1) { fill: #ffd3a8; } </style> If you want to also apply different colors to the other values, change the bold number to any desired displayed number and it should work as expected. Leon13 1 Quote Link to comment Share on other sites More sharing options...
Leon13 Posted May 29, 2020 Report Share Posted May 29, 2020 2 hours ago, SinJunYoung said: Hello, you can also try getting the nth child but will be a static change of color display. But since the chart will always return the blank in the first line, we can always modify the 1st one to be set as orange. Try pasting this to the header as well: <style> rect.highcharts-point.highcharts-color-0:nth-child(1) { fill: #ffd3a8; } </style> If you want to also apply different colors to the other values, change the bold number to any desired displayed number and it should work as expected. Excellent solution, worked like a charm. Hastur's solution worked too, but seams to be resource intensive. (Perhaps my machine just acted up..) Thank you both!! Quote Link to comment Share on other sites More sharing options...
SinJunYoung Posted May 30, 2020 Report Share Posted May 30, 2020 Thanks, Leon13! Here is also a reference regarding Charts: https://howto.caspio.com/datapages/charts/ Quote Link to comment Share on other sites More sharing options...
autonumber Posted January 4, 2022 Report Share Posted January 4, 2022 Hello! I just want to add this forum post that might also help you. Quote Link to comment Share on other sites More sharing options...
DRomano Posted July 31, 2022 Report Share Posted July 31, 2022 This works perfectly! Is there a way to add other chart columns to this? I want to add other columns from the chart using different colors based on "status" . I can change the color for one column but need to change for multiple columns some different statuses. Quote Link to comment Share on other sites More sharing options...
futurist Posted January 8, 2023 Report Share Posted January 8, 2023 On 5/29/2020 at 7:43 AM, Hastur said: Hello! To change the color you need to use additional JS code. It will parse the data in chart and change the color according to name of the column. Here is the code: <script type="text/javascript"> document.addEventListener('DataPageReady', chartUpdateHandler); function chartUpdateHandler(event) { var cleaner = function(interv) { clearInterval(interv); } let interv = setInterval(() => { if (!!Highcharts) { const options = Highcharts.charts[0].series[0].data; let data = []; options.forEach(option => { let localData = {}; localData.y = option.y; localData.name = option.name; if(option.name === "(blank)") { localData.color = '#ee5921'; } else { localData.color = '#3186AD'; } data.push(localData); }) Highcharts.charts[0].update({ series: { data: data } }); cleaner(interv); } }, 200); } </script> You need to insert this code into the Header of the report DataPage. Do not forget to disable the HTML editor. Hi, sharing in here a script that I found that allows you to check if an element exists (followed by your code if that element in fact exists) instead of using a timer (setInterval): function waitForElm(selector) { return new Promise(resolve => { if (document.querySelector(selector)) { return resolve(document.querySelector(selector)); } const observer = new MutationObserver(mutations => { if (document.querySelector(selector)) { resolve(document.querySelector(selector)); observer.disconnect(); } }); observer.observe(document.body, { childList: true, subtree: true }); }); } To use it: waitForElm('.some-class').then((elm) => { console.log('Element is ready'); console.log(elm.textContent); }); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.