Solved

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

Posted on 2016-09-14
4
28 Views
Last Modified: 2016-10-04
{
            "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
0
Comment
Question by:Reek Majumder
  • 2
  • 2
4 Comments
 
LVL 63

Accepted Solution

by:
Zvonko earned 500 total points (awarded by participants)
ID: 41799475
Check this:
{
	"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":"cornflowerblue",
			"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

0
 
LVL 63

Expert Comment

by:Zvonko
ID: 41799477
...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

0
 
LVL 33

Expert Comment

by:Slick812
ID: 41799922
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?
0
 
LVL 33

Expert Comment

by:Slick812
ID: 41827710
No comment has been added from the author, so forced closing as abandoned, with best solution presented
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
In this Micro Tutorial viewers will learn how to create a CSS image sprite (In a later tutorial, viewers will learn how to use CSS and HTML to create a navigation menu using this sprite) Open a new Photoshop document with a width of (Icon width)x(N…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now