文本主要指的是Label标签 和 Info提示, 文本一般由文字和文字边框组成
文本样式一般在GView上进行全局设置, 也可以在节点或链路上分别设置, 全局属性名和节点/链路的属性名一致
有如下可选项:
node.set("label_position", "center");
gView.set("label_position", "bottom");
仅对节点有效
有如下可选项
如果没有指定label_direction, 会根据label_position自动设置label_direction方向
node.set("label_direction", "left");
gView.set("label_direction", "right");
仅对节点有效
node.set("label_gap", 6);
gView.set("label_gap", 20); //全局设置
仅对节点有效
属性在节点和链路使用上有所差异
node.set("label_rotation", "60");
link.set("label_direction", false);
gView.set("node_label_rotation", "60"); //全局设置
gView.set("link_label_direction", false); //全局设置
请参考CanvasRenderingContext2D.font
node.set("label_font", "italic 600 24px sans-serif");
gView.set("label_font", "12px Arial, sans-serif"); //全局设置
node.set("label_offset", {x:10, y:20}});
gView.set("label_offset", 20); //全局设置
label_offset等价于label_offset_x+label_offset_y, 不过label_offset的优先级高,会优先使用
node.set("label_offset_x", 10);
gView.set("label_offset_x", 20); //全局设置
node.set("label_offset_y", 10);
gView.set("label_offset_y", 20); //全局设置
有如下可选项
默认换行符为"\n", 可以通过设置CANVAS_2D_TEXT_NEWLINE默认属性来修改默认值
node.set("label_align", "left");
gView.set("label_align", "right"); //全局设置
z.setDefault("CANVAS_2D_TEXT_NEWLINE","\n\r"); //修改换行符
node.set("label_style", {
shadowColor: "red",
shadowBlur: 10,
shadowOffsetX: 5,
shadowOffsetY: 5
});
gView.set("label_style", {shadowColor: "red"}); //全局设置
node.set("label_box_padding", 2);
gView.set("label_box_padding", 3); //全局设置
填充样式可以是颜色、渐变色和图片纹理, 请参考填充和画笔样式#fill
node.set("label_fill", "linear_gradient"); //渐变类型
node.set("label_fill_gradient_direction", "lt_to_rb"); //渐变类型
node.set("label_fill_gradient_colors", { //渐变颜色
0: "black", //起始颜色为black
1: "red" //结束颜色为red
});
请参考填充和画笔样式#fill-gradient-direction
node.set("fill_gradient_direction", "lt_to_rb");
渐变颜色由百分比位置(0-1)和颜色组成, 请参考填充和画笔样式#fill-gradient-colors
node.set("label_fill_gradient_colors", {
0: "black", //起始颜色为black
1: "red" //结束颜色为red
});
属性值可以是注册的图片, 也可以是img对象, 请参考填充和画笔样式#fill-pattern-image
node.set("label_fill_pattern_image", "windmill");
画笔样式可以是颜色、渐变色和图片纹理, 请参考填充和画笔样式#stroke
node.set("label_stroke", "LightSkyBlue"); //颜色
node.set("label_stroke", "linear_gradient"); //渐变类型
node.set("label_fill_gradient_direction", "lt_to_rb"); //渐变方向
node.set("label_fill_gradient_colors", { //渐变颜色
0: "black", //起始颜色为black
1: "red" //结束颜色为red
});
请参考填充和画笔样式#stroke-gradient-direction
node.set("label_stroke_gradient_direction","lt_to_rb");
渐变颜色由百分比位置(0-1)和颜色组成, 请参考填充和画笔样式#stroke-gradient-colors
node.set("label_stroke_gradient_colors", {
0: "black", //起始颜色为black
0.5: "red", //中间50%位置的颜色为red
1: "white" //结束颜色为white
});
请参考填充和画笔样式#stroke-stroke-line-width
node.set("label_stroke_line_width", 2);
使用一组值来指定描述模式的线和间隙的交替长度, 请参考填充和画笔样式#stroke-stroke-line-dash
node.set("label_stroke_line_dash", [6, 3]);
可以通过设置offset实现动画效果, 请参考填充和画笔样式#stroke-stroke-line-dash-offset
node.set("label_stroke_line_dash_offset", 2);
填充样式可以是颜色、渐变色和图片纹理, 请参考填充和画笔样式#fill
node.set("label_box_fill", "linear_gradient"); //渐变类型
node.set("label_box_fill_gradient_direction", "lt_to_rb"); //渐变类型
node.set("label_box_fill_gradient_colors", { //渐变颜色
0: "black", //起始颜色为black
1: "red" //结束颜色为red
});
请参考填充和画笔样式#fill-gradient-direction
node.set("fill_gradient_direction", "lt_to_rb");
渐变颜色由百分比位置(0-1)和颜色组成, 请参考填充和画笔样式#fill-gradient-colors
node.set("label_box_fill_gradient_colors", {
0: "black", //起始颜色为black
1: "red" //结束颜色为red
});
属性值可以是注册的图片, 也可以是img对象, 请参考填充和画笔样式#fill-pattern-image
node.set("fill_pattern_image", "windmill");
画笔样式可以是颜色、渐变色和图片纹理, 请参考填充和画笔样式#stroke
node.set("label_box_stroke", "LightSkyBlue"); //颜色
node.set("label_box_stroke", "linear_gradient"); //渐变类型
node.set("label_box_fill_gradient_direction", "lt_to_rb"); //渐变方向
node.set("label_box_fill_gradient_colors", { //渐变颜色
0: "black", //起始颜色为black
1: "red" //结束颜色为red
});
请参考填充和画笔样式#stroke-gradient-direction
node.set("label_box_stroke_gradient_direction","lt_to_rb");
渐变颜色由百分比位置(0-1)和颜色组成, 请参考填充和画笔样式#stroke-gradient-colors
node.set("label_box_stroke_gradient_colors", {
0: "black", //起始颜色为black
0.5: "red", //中间50%位置的颜色为red
1: "white" //结束颜色为white
});
请参考填充和画笔样式#stroke-stroke-line-width
node.set("label_box_stroke_line_width", 2);
使用一组值来指定描述模式的线和间隙的交替长度, 请参考填充和画笔样式#stroke-stroke-line-dash
node.set("label_box_stroke_line_dash", [6, 3]);
可以通过设置offset实现动画效果, 请参考填充和画笔样式#stroke-stroke-line-dash-offset
node.set("label_box_stroke_line_dash_offset", 2);
请参考CanvasRenderingContext2D.font
node.set("info_font", "italic 600 24px sans-serif");
gView.set("info_font", "12px Arial, sans-serif"); //全局设置
node.set("info_offset", {x:10, y:20}});
gView.set("info_offset", 20); //全局设置
info_offset等价于info_offset_x+info_offset_y, 不过info_offset的优先级较高,会优先使用
node.set("info_offset_x", 10);
gView.set("info_offset_x", 20); //全局设置
node.set("info_offset_y", 10);
gView.set("info_offset_y", 20); //全局设置
有如下可选项
默认换行符为"\n", 可以通过设置CANVAS_2D_TEXT_NEWLINE默认属性来修改默认值
node.set("info_align", "left");
gView.set("info_align", "right"); //全局设置
z.setDefault("CANVAS_2D_TEXT_NEWLINE","\n\r"); //修改换行符
node.set("info_style", {
shadowColor: "red",
shadowBlur: 10,
shadowOffsetX: 5,
shadowOffsetY: 5
});
gView.set("info_style", {shadowColor: "red"}); //全局设置
node.set("info_box_padding", 2);
gView.set("info_box_padding", 3); //全局设置
请参考填充和画笔样式#fill
node.set("info_fill", "linear_gradient"); //渐变类型
node.set("info_fill_gradient_direction", "lt_to_rb"); //渐变类型
node.set("info_fill_gradient_colors", { //渐变颜色
0: "black", //起始颜色为black
1: "red" //结束颜色为red
});
请参考填充和画笔样式#fill-gradient-direction
node.set("fill_gradient_direction", "lt_to_rb");
渐变颜色由百分比位置(0-1)和颜色组成, 请参考填充和画笔样式#fill-gradient-colors
node.set("info_fill_gradient_colors", {
0: "black", //起始颜色为black
1: "red" //结束颜色为red
});
属性值可以是注册的图片, 也可以是img对象, 请参考填充和画笔样式#fill-pattern-image
node.set("info_fill_pattern_image", "windmill");
画笔样式可以是颜色、渐变色和图片纹理, 请参考填充和画笔样式#stroke
node.set("info_stroke", "LightSkyBlue"); //颜色
node.set("info_stroke", "linear_gradient"); //渐变类型
node.set("info_fill_gradient_direction", "lt_to_rb"); //渐变方向
node.set("info_fill_gradient_colors", { //渐变颜色
0: "black", //起始颜色为black
1: "red" //结束颜色为red
});
请参考填充和画笔样式#stroke-gradient-direction
node.set("info_stroke_gradient_direction","lt_to_rb");
渐变颜色由百分比位置(0-1)和颜色组成, 请参考填充和画笔样式#stroke-gradient-colors
node.set("info_stroke_gradient_colors", {
0: "black", //起始颜色为black
0.5: "red", //中间50%位置的颜色为red
1: "white" //结束颜色为white
});
请参考填充和画笔样式#stroke-stroke-line-width
node.set("info_stroke_line_width", 2);
使用一组值来指定描述模式的线和间隙的交替长度, 请参考填充和画笔样式#stroke-stroke-line-dash
node.set("info_stroke_line_dash", [6, 3]);
可以通过设置offset实现动画效果, 请参考填充和画笔样式#stroke-stroke-line-dash-offset
node.set("info_stroke_line_dash_offset", 2);
填充样式可以是颜色、渐变色和图片纹理, 请参考填充和画笔样式#fill
node.set("info_box_fill", "linear_gradient"); //渐变类型
node.set("info_box_fill_gradient_direction", "lt_to_rb"); //渐变类型
node.set("info_box_fill_gradient_colors", { //渐变颜色
0: "black", //起始颜色为black
1: "red" //结束颜色为red
});
请参考填充和画笔样式#fill-gradient-direction
node.set("fill_gradient_direction", "lt_to_rb");
渐变颜色由百分比位置(0-1)和颜色组成, 请参考填充和画笔样式#fill-gradient-colors
node.set("info_box_fill_gradient_colors", {
0: "black", //起始颜色为black
1: "red" //结束颜色为red
});
属性值可以是注册的图片, 也可以是img对象, 请参考填充和画笔样式#fill-pattern-image
node.set("fill_pattern_image", "windmill");
画笔样式可以是颜色、渐变色和图片纹理, 请参考填充和画笔样式#stroke
node.set("info_box_stroke", "LightSkyBlue"); //颜色
node.set("info_box_stroke", "linear_gradient"); //渐变类型
node.set("info_box_fill_gradient_direction", "lt_to_rb"); //渐变方向
node.set("info_box_fill_gradient_colors", { //渐变颜色
0: "black", //起始颜色为black
1: "red" //结束颜色为red
});
请参考填充和画笔样式#stroke-gradient-direction
node.set("info_box_stroke_gradient_direction","lt_to_rb");
渐变颜色由百分比位置(0-1)和颜色组成, 请参考填充和画笔样式#stroke-gradient-colors
node.set("info_box_stroke_gradient_colors", {
0: "black", //起始颜色为black
0.5: "red", //中间50%位置的颜色为red
1: "white" //结束颜色为white
});
请参考填充和画笔样式#stroke-stroke-line-width
node.set("info_box_stroke_line_width", 2);
使用一组值来指定描述模式的线和间隙的交替长度, 请参考填充和画笔样式#stroke-stroke-line-dash
node.set("info_box_stroke_line_dash", [6, 3]);
可以通过设置offset实现动画效果, 请参考填充和画笔样式#stroke-stroke-line-dash-offset
node.set("info_box_stroke_line_dash_offset", 2);