Avatar of Reek Majumder
Reek Majumder
 asked on

change color of a diagram element which is stored in the server and retrived as JSON format

{
            "type": "vsm.box",
            "name": "VSM Box",
            "bold": true,
            "italic": true,
            "underline": true,
            "size": {
                "width": 100,
                "height": 100
            },
            "description": "Box",
            "position": {
                "x": 120,
                "y": 290
            },
            "angle": 0,
            "id": "b1b65721-ac0b-4687-a081-88b28109cb9b",
            "embeds": "",
            "z": 1,
            "attrs": {
                "rect": {
                    "stroke": "#000000",
                    "stroke-width": 1,
                    "stroke-dasharray": "0"
                },
                "text": {
                    "text": "Box",
                    "font-family": "Arial",
                    "stroke": "#000000",
                    "stroke-width": 0,
                    "font-weight": 400,
                    "font-style": "normal",
                    "text-decoration": ""
                }
            }
        }

Open in new window

This is one of my program element in JSOn now i would like to fill color to it.
accor ding to rappid api if i change coding it is pushed to
attrs---> rect---->fill:color
JavaScriptJSONCSS

Avatar of undefined
Last Comment
Member_2_248744

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Zvonko

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Zvonko

...or the color in hex:
{
	"type": "vsm.box",
	"name": "VSM Box",
	"bold": true,
	"italic": true,
	"underline": true,
	"size": {
		"width": 100,
		"height": 100
	},
	"description": "Box",
	"position": {
		"x": 120,
		"y": 290
	},
	"angle": 0,
	"id": "b1b65721-ac0b-4687-a081-88b28109cb9b",
	"embeds": "",
	"z": 1,
	"attrs": {
		"rect": {
			"fill":"#6495ED",
			"stroke": "#000000",
			"stroke-width": 1,
			"stroke-dasharray": "0"
		},
		"text": {
			"text": "Box",
			"font-family": "Arial",
			"stroke": "#000000",
			"stroke-width": 0,
			"font-weight": 400,
			"font-style": "normal",
			"text-decoration": ""
		}
	}
}

Open in new window

Member_2_248744

greetings Reek Majumder, , It looks like you want to "Change" this fill color in the browser javascript operations that receive the "JSON string" from the server, I guess it uses AJAX to get this "JSON string", it is possible to add the fillcolor property to the rect object in the javascript string, but it may be less difficult to to add the fillcolor property AFTER the "JSON string" is converted to a javascript Object in the code progression. Can you show us the AJAX "JSON string" retrieval  code in the javascript?
Member_2_248744

No comment has been added from the author, so forced closing as abandoned, with best solution presented
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23