Coloring a Line


I want color a line from January 1950 to December 2023 in blue and a projection from January 2024 to December 2030 in red.

Of course, I have the data from January 1950 for December 2030 in the data file.

Can this be done using a script?

Many thanks in advance.

Best wishes,

Hi Thomas,

You can use a custom colour script with YEARNUM()>2023 for red and the rest in blue, as per this example:


Thanks Darren, and how easy again.

Hi Darren,

I need your help again.

In my new analysis, I have monthly data and would like to color the data line red from July 1997, for example. The particular problem here is that the start of the new color falls on a selected month and not on the start of a new year.

Using the following script would color the line at the beging of 1998.

YEARNUM() > 1997

screenshot - 0000

If I use the following script, only the months July, August, September, October, November and December of each year are colored differently.

MONTHNUM() >7 and YEARNUM() > 1996

screenshot - 0002

What is the correct script to color the data line red from July 1997?


Hi Thomas,

In this case you would need to specify the midyear date using the BARDATE() and STRDATE() functions:


Hi Darren,

Thanks for your response, your recommendation works perfect.

In the following diagram you can see that the blue line is colored green from July 1997 (according to your script). That’s how it should be.

Then I added a NEW data series from July 1997, which is colored red.
ISM Manufacturing PMI

Now my question: Is it possible to make the green line invisible so that only the red line is visible?

I have worked with the IF() and HIDDEN() function to make the green colored line invisible but without any success.

Here is my script approach:

Line1 = BARDATE()>STRDATE(DATE=1997-07-31) ;
Line2 = IF(Line1 == 1, HIDDEN(), 0) ;

As mentioned, the script doesn’t work. Any suggestion?

Best wishes,

Hi Thomas,

You could change the custom colour to the same as the chart background, so it appears hidden after that date:

Hi Darren,

I have already tried to change the custom color to match the chart background, but I am using the “Theme -> Light” setting and have disabled the “White Chart Background” property, so I have a light gray background and there is no gray color available to match the light gray background.

Is there a scripting solution to make the green line invisible?


Hi Thomas,

Try this in a Show Plot with the PMI chart made invisible in the Structure Panel. The GETDATA function in P2 needs to reference the data series in red:

IF(BARDATE()<STRDATE(DATE=1997-07-31), P1, P2)

Hi Darren,

Many thanks for your efforts about this truly trick issue.

I followed your advice and here is the result:

As you can see it works! But I get a vertical line to “0” and a horizontal line at “0”.

Can this vertical and horizontal line removed?

Can you please give me some information about the following code line:


What does “CODE=DATA2” mean?

Congratulations on your new forum website. A lot of new functions and settings. It will take some time to get used to the new design.

The old design was simpler and clearer. But from an administrator’s point of view, the new design is certainly better in order to better meet the legal and especially the privacy settings.

In any case, the new design is considerably more flexible than the old one, which is clearly demonstrated by the changes between yesterday and today.

The ever-increasing complexity is the price we have to pay for ever more sophisticated systems, better performance and better privacy protection.

Keep up the great work you are doing at Optuma. :smiley:

Best wishes,

1 Like

Hi Darren,

I think I have solved the issue with vertical and horizontal lines. Instead of code line P2 is use the function HIDDEN() in the IF() function.

I even replaced code line P1 in the IF() function with simple CLOSE().

Here is the simplified script:


The chart:

Many thanks,