Comments (2)
参看app/demo2.html 或者 app/scripts/main.js,注意images参数的设置,支持png,svg等图标,支持附加样式
Q.registerImage('lamp', Q.Shapes.getShape(Q.Consts.SHAPE_CIRCLE, -8, -8, 16, 16));
var lampGradient = new Q.Gradient(Q.Consts.GRADIENT_TYPE_RADIAL, [Q.toColor(0xAAFFFFFF), Q.toColor(0x33EEEEEE), Q.toColor(0x44888888), Q.toColor(0x33666666)],
[0.1, 0.3, 0.7, 0.9], 0, -0.2, -0.2);
function createLampStyles(color) {
var styles = {};
styles[Q.Styles.SHAPE_FILL_COLOR] = color;
styles[Q.Styles.SHAPE_STROKE] = 0.5;
styles[Q.Styles.SHAPE_STROKE_STYLE] = '#CCC';
styles[Q.Styles.LABEL_BACKGROUND_COLOR] = '#FF0';
styles[Q.Styles.SHAPE_FILL_COLOR] = color;
styles[Q.Styles.LABEL_SIZE] = {width: 100, height: 20};
styles[Q.Styles.LABEL_PADDING] = 5;
styles[Q.Styles.LABEL_OFFSET_Y] = -10;
styles[Q.Styles.SHAPE_FILL_GRADIENT] = lampGradient;
styles[Q.Styles.LABEL_POSITION] = Q.Position.CENTER_TOP;
styles[Q.Styles.LABEL_ANCHOR_POSITION] = Q.Position.LEFT_BOTTOM;
return styles;
}
$('.graph-editor').graphEditor({
data: 'data/topo2.json',
images: [
{name: '预定义图形', images: graphs},
{
name: 'Cisco图标',
root: 'data/cisco/',
images: ['ATMSwitch.png', 'multilayerSwitch.png', 'workgroupSwitch.png', 'workgroupSwitchSubdued.png', '100BaseT_hub.png', 'cisco_hub.png', 'switch1100.png']
},{
name: '自定义图标',
imageWidth: 30,
imageHeight: 30,
images: [{
image: 'lamp',
properties: {
name: 'Message'
},
styles: createLampStyles('#F00')
}, {
image: 'lamp',
properties: {
name: 'Message'
},
styles: createLampStyles('#FF0')
}, {
image: 'lamp',
properties: {
name: 'Message'
},
styles: createLampStyles('#0F0')
}, {
image: 'lamp',
properties: {
name: 'Message'
},
styles: createLampStyles('#0FF')
}, {
image: 'lamp',
properties: {
name: 'Message'
},
styles: createLampStyles('#00F')
}, {
image: 'lamp',
properties: {
name: 'Message'
},
styles: createLampStyles('#F0F')
}]
}]
});
from graph.editor.
TKS
from graph.editor.
Related Issues (10)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graph.editor.