06-02-2018 11:43
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

06-02-2018 11:43
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Changing the fill attribute on a rect element works fine:
if (data.colorBackground) { bGround.style.fill = data.colorBackground; }
But I cannot find an equivalent for changing a gradient-color[1/2] attribute of a gradientRect element:
if (data.colorBackground) { bGroundGrade.style.gradientColor1 = data.colorBackground; }
Produces: Unhandled TypeError: Cannot set property 'gradientColor1' of undefined
Meanwhile,
if (data.colorBackground) { bGroundGrade.gradientColor1 = data.colorBackground; }
doesn't throw an error, but neither does it change my background gradient color.
Any help would be appreciated, thanks!
Answered! Go to the Best Answer.

Accepted Solutions
06-05-2018 17:40
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


06-05-2018 17:40
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
06-05-2018 17:21
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

06-05-2018 17:21
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hey, I'm going through the same thing and will definitely find an answer somehow. I'll let you know what I discover, if anything. Do you have any idea how to change the viewport-fill of an SVG by chance? Pretty similar problem.

06-05-2018 17:40
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


06-05-2018 17:40
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
Try:
bGroundGrade.gradient.colors.c1 = data.colorBackground;
06-05-2018 18:14
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

06-05-2018 18:14
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
That worked wonderfully, thank you. Any hints on changing the viewport fill color?

06-05-2018 19:08
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

06-05-2018 19:08
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I decided that I can just use a rect across the entire background and change its .style.fill property instead.

