GridLine 网格线
阅读时间约 2 分钟
网格线插件,多用于辅助绘图
createGraph({data: { nodes: [{ id: 'node-1' }] },node: { style: { fill: '#7e3feb' } },edge: { style: { stroke: '#8b9baf' } },layout: { type: 'force' },behaviors: ['drag-canvas'],plugins: [{ type: 'grid-line', size: 30 }],},{ width: 600, height: 300 },(gui, graph) => {const LINE_STYLE = ['none', 'hidden', 'dotted', 'dashed', 'solid', 'double', 'groove', 'ridge', 'inset', 'outset'];const options = {type: 'grid-line',border: true,borderLineWidth: 1,borderStroke: '#eee',borderStyle: 'solid',follow: false,lineWidth: 1,size: 20,stroke: '#eee',};const optionFolder = gui.addFolder('Gird Line Options');optionFolder.add(options, 'type').disable(true);optionFolder.add(options, 'size', 1, 50, 1);optionFolder.add(options, 'lineWidth', 1, 10, 1);optionFolder.addColor(options, 'stroke');optionFolder.add(options, 'border');optionFolder.add(options, 'borderLineWidth', 1, 10, 1);optionFolder.add(options, 'borderStyle', LINE_STYLE);optionFolder.addColor(options, 'borderStroke');optionFolder.add(options, 'follow');optionFolder.onChange(({ property, value }) => {graph.updatePlugin({key: 'grid-line',[property]: value,});graph.render();});},);
参考示例:
grid-line
| string
此插件已内置,你可以通过 type: 'grid-line'
来使用它。
boolean Default:
true
是否显示边框
number Default:
1
边框线宽
string Default:
'#0001'
边框颜色
完整属性定义参考 CSS border-color
string Default:
'solid'
边框样式
完整属性定义参考 CSS border-style
boolean Default:
false
是否跟随图移动
number | string Default:
1
网格线宽
number Default:
20
单个网格的大小
string Default:
'#0001'
网格线颜色