Mixed Chart Graph Details

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt

oleviasharbaugh
Posts: 17
Joined: Thu Aug 24, 2023 9:42 am

Mixed Chart Graph Details

Postby oleviasharbaugh » Thu Aug 24, 2023 12:42 pm

I currently have a mixed chart created in Eviews 12 that includes a bar chart with levels and a line indicating percent changes from year to year. I would like to make the 2024 bar a different color (red) as well as shade the area behind this bar yellow to show that its a forecast and not historical data. How can I do this for a mixed chart? Below is my current program. The last line is my attempt at shading behind the bar for 2024's data, but Eviews seems to be disregarding it. I don't get an error, it just doesn't add the shading.

group valgroup_{%x} {%x}_value_{%y} {%x}_value_{%y}_pc
freeze(g_{%x}_value_{%y}) valgroup_{%x}.mixed bar(1) line(2)
g_{%x}_value_{%y}.addtext(t, font("arial",14, b)) {%x } Construction Starts in {%longstate}
g_{%x}_value_{%y}.options gridnone
g_{%x}_value_{%y}.setelem(2) axis(r)
g_{%x}_value_{%y}.axis(r) format(suffix="%")
g_{%x}_value_{%y}.axis(r) range(minmax)
g_{%x}_value_{%y}.axis(l) format(prefix="$")
g_{%x}_value_{%y}.setelem(1) linecolor(@rgb(255,87,59))
g_{%x}_value_{%y}.setelem(1) symbol(FILLEDCIRCLE)
g_{%x}_value_{%y}.axis(l) linearzero
g_{%x}_value_{%y}.axis(r) linearzero
g_{%x}_value_{%y}.addtext(r,font(b,12)) "Percent Change"
g_{%x}_value_{%y}.addtext(l,font(b,12)) "Millions of USD"
g_{%x}_value_{%y}.axis overlap
g_{%x}_value_{%y}.options barlabelabove
g_{%x}_value_{%y}.setelem(1) fcolor(63,79,170)
g_{%x}_value_{%y}.setelem(1) legend(Value)
g_{%x}_value_{%y}.setelem(2) legend(Percentage Change (Y/Y))
g_{%x}_value_{%y}.draw(shade, bottom,rgb(255,255,180)) 2024 2024

Any help is much appreciated!

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13323
Joined: Tue Sep 16, 2008 5:38 pm

Re: Mixed Chart Graph Details

Postby EViews Gareth » Thu Aug 24, 2023 12:51 pm

Worked for me in a test program, can you confirm this code doesn't work for you?

Code: Select all

create m 1990 2024

%x = "foo"
%y = "bar"

series {%x}_value_{%y} = @nrnd
series {%x}_value_{%y}_pc = @nrnd

group valgroup_{%x} {%x}_value_{%y} {%x}_value_{%y}_pc
freeze(g_{%x}_value_{%y}) valgroup_{%x}.mixed bar(1) line(2)
g_{%x}_value_{%y}.addtext(t, font("arial",14, b)) {%x } Construction Starts in {%longstate}
g_{%x}_value_{%y}.options gridnone
g_{%x}_value_{%y}.setelem(2) axis(r)
g_{%x}_value_{%y}.axis(r) format(suffix="%")
g_{%x}_value_{%y}.axis(r) range(minmax)
g_{%x}_value_{%y}.axis(l) format(prefix="$")
g_{%x}_value_{%y}.setelem(1) linecolor(@rgb(255,87,59))
g_{%x}_value_{%y}.setelem(1) symbol(FILLEDCIRCLE)
g_{%x}_value_{%y}.axis(l) linearzero
g_{%x}_value_{%y}.axis(r) linearzero
g_{%x}_value_{%y}.addtext(r,font(b,12)) "Percent Change"
g_{%x}_value_{%y}.addtext(l,font(b,12)) "Millions of USD"
g_{%x}_value_{%y}.axis overlap
g_{%x}_value_{%y}.options barlabelabove
g_{%x}_value_{%y}.setelem(1) fcolor(63,79,170)
g_{%x}_value_{%y}.setelem(1) legend(Value)
g_{%x}_value_{%y}.setelem(2) legend(Percentage Change (Y/Y))
g_{%x}_value_{%y}.draw(shade, bottom,rgb(255,255,180)) 2024 2024
Follow us on Twitter @IHSEViews

oleviasharbaugh
Posts: 17
Joined: Thu Aug 24, 2023 9:42 am

Re: Mixed Chart Graph Details

Postby oleviasharbaugh » Thu Aug 24, 2023 2:15 pm

Interesting. That code does work for me but I don't understand how it differs from my own. Does it have something to do with the fact that you define the two variables as series? And if so, how would I do that if I am also running a loop like so:

subroutine graphtest

smpl {%begindate} {%enddate}

for %x Bridge Street_and_Bridge Dam_and_Reservoir Environmental_Public_Works Other_Nonbuilding Power_and_Utilites Sewer Street Water Recreational_Building Dormitory Government_Building Healthcare_Building Hotel Manufacturing Transportation_Building Office Commercial_Garage Religious_Building Educational_Building Retail Warehouse Apartment_Building Single_Family Two_Family MultiFamily Nonresidential Residential_Building NonBuilding Commercial_Building Institutional_Building
for %y {%state}
group valgroup_{%x} {%x}_value_{%y} {%x}_value_{%y}_pc
freeze(g_{%x}_value_{%y}) valgroup_{%x}.mixed bar(1) line(2)
g_{%x}_value_{%y}.addtext(t, font("arial",14, b)) {%x } Construction Starts in {%longstate}
g_{%x}_value_{%y}.options gridnone
g_{%x}_value_{%y}.setelem(2) axis(r)
g_{%x}_value_{%y}.axis(r) format(suffix="%")
g_{%x}_value_{%y}.axis(r) range(minmax)
g_{%x}_value_{%y}.axis(l) format(prefix="$")
g_{%x}_value_{%y}.setelem(1) linecolor(@rgb(255,87,59))
g_{%x}_value_{%y}.setelem(1) symbol(FILLEDCIRCLE)
g_{%x}_value_{%y}.axis(l) linearzero
g_{%x}_value_{%y}.axis(r) linearzero
g_{%x}_value_{%y}.addtext(r,font(b,12)) "Percent Change"
g_{%x}_value_{%y}.addtext(l,font(b,12)) "Millions of USD"
g_{%x}_value_{%y}.axis overlap
g_{%x}_value_{%y}.options barlabelabove
g_{%x}_value_{%y}.setelem(1) fcolor(63,79,170)
g_{%x}_value_{%y}.setelem(1) legend(Value)
g_{%x}_value_{%y}.setelem(2) legend(Percentage Change (Y/Y))
g_{%x}_value_{%y}.datelabel format("YYYY")
g_{%x}_value_{%y}.draw(shade, bottom,rgb(255,255,180)) 2024 2024
next
next
endsub

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13323
Joined: Tue Sep 16, 2008 5:38 pm

Re: Mixed Chart Graph Details

Postby EViews Gareth » Thu Aug 24, 2023 2:25 pm

Could you provide a workfile and code that runs on that workfile that does not work?
Follow us on Twitter @IHSEViews

oleviasharbaugh
Posts: 17
Joined: Thu Aug 24, 2023 9:42 am

Re: Mixed Chart Graph Details

Postby oleviasharbaugh » Fri Aug 25, 2023 11:59 am

Attached are simplified versions of my programs/workfiles. I do notice that when I increase the range of my shading (from 1 year shaded to 2 years) it will include the shading, but it is offset from the beginning of the bar in the year that I would like the shading to begin. I would like the shading to be in line with the bars if possible.
Attachments
sample.wf1
(12.5 KiB) Downloaded 115 times
sample1.prg
(2.35 KiB) Downloaded 116 times

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13323
Joined: Tue Sep 16, 2008 5:38 pm

Re: Mixed Chart Graph Details

Postby EViews Gareth » Fri Aug 25, 2023 1:11 pm

Ah, the issue is that your workfile is annual. You cannot shade a single observation.
Follow us on Twitter @IHSEViews

oleviasharbaugh
Posts: 17
Joined: Thu Aug 24, 2023 9:42 am

Re: Mixed Chart Graph Details

Postby oleviasharbaugh » Fri Aug 25, 2023 1:17 pm

Is that something that is unique to the mixed chart graphic? I was able to shade one observation when I was only using the bar chart.
Attachments
Screenshot 2023-08-25 151652.png
Screenshot 2023-08-25 151652.png (14.13 KiB) Viewed 11360 times

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13323
Joined: Tue Sep 16, 2008 5:38 pm

Re: Mixed Chart Graph Details

Postby EViews Gareth » Fri Aug 25, 2023 2:20 pm

Its something unique to bar charts ;)
Follow us on Twitter @IHSEViews


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 23 guests