翻譯|使用教程|編輯:楊鵬連|2020-08-25 11:14:38.577|閱讀 313 次
概述:本教程介紹如何創(chuàng)建分級(jí)面板,在“刻度”面板Panel.Graduated,平定期刻度/文字標(biāo)簽沿主子圖的行程形狀。刻度面板可以視為顯示一系列值的比例尺。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
GoJS是一款功能強(qiáng)大,快速且輕量級(jí)的流程圖控件,可幫助你在JavaScript 和HTML5 Canvas程序中創(chuàng)建流程圖,且極大地簡(jiǎn)化您的JavaScript / Canvas 程序。
刻度線外觀
刻度線相對(duì)于主要形狀路徑的出現(xiàn)由一些屬性控制:
設(shè)置graduatedStart和/或graduatedEnd僅允許沿主筆劃的一部分繪制刻度線:
diagram.add( $(go.Part, "Graduated", $(go.Shape, { geometryString: "M0 0 H400" }), $(go.Shape, { geometryString: "M0 0 V10", graduatedStart: .25, graduatedEnd: .75 }) ));
在這種情況下,現(xiàn)在僅在主體形狀的中部繪制刻度線。
設(shè)置alignmentFocus為go.Spot.Bottom將會(huì)使刻度線的底部與主筆劃對(duì)齊:
diagram.add( $(go.Part, "Graduated", $(go.Shape, { geometryString: "M0 0 H400" }), $(go.Shape, { geometryString: "M0 0 V10", alignmentFocus: go.Spot.Bottom }) ));
設(shè)置alignmentFocus為go.Spot.Center將會(huì)使刻度線在路徑中居中:
diagram.add( $(go.Part, "Graduated", $(go.Shape, { geometryString: "M0 0 H400" }), $(go.Shape, { geometryString: "M0 0 V10 M0 20 V30", alignmentFocus: go.Spot.Center }) ));
注意形狀的幾何形狀中的間隙。
設(shè)置segmentOffset標(biāo)簽可以使它們?cè)诳潭染€附近更具可讀性:diagram.add( $(go.Part, "Graduated", $(go.Shape, { geometryString: "M0 0 H400" }), $(go.Shape, { geometryString: "M0 0 V10" }), // offset to display below ticks $(go.TextBlock, { segmentOffset: new go.Point(0, 12) }) ));
diagram.add( $(go.Part, "Graduated", $(go.Shape, { geometryString: "M0 0 H400" }), $(go.Shape, { geometryString: "M0 0 V10" }), // change the angle of the text $(go.TextBlock, { segmentOrientation: go.Link.OrientMinus90 }) ));
diagram.add( $(go.Part, "Graduated", $(go.Shape, { geometryString: "M0 0 H400" }), $(go.Shape, { geometryString: "M0 0 V10", alignmentFocus: go.Spot.Bottom }), $(go.TextBlock, { alignmentFocus: go.Spot.Left, segmentOffset: new go.Point(0, -12), segmentOrientation: go.Link.OrientMinus90 } ) ));
diagram.add( $(go.Part, "Graduated", $(go.Shape, { geometryString: "M0 0 L285 285" }), $(go.Shape, { geometryString: "M0 0 V10", alignmentFocus: go.Spot.Bottom }), $(go.TextBlock, { alignmentFocus: go.Spot.Left, segmentOffset: new go.Point(0, -12), segmentOrientation: go.Link.OrientMinus90 } ) ));
diagram.add( $(go.Part, "Graduated", $(go.Shape, "Curve1", { desiredSize: new go.Size(285, 285) }), $(go.Shape, { geometryString: "M0 0 V10", alignmentFocus: go.Spot.Bottom }), $(go.TextBlock, { alignmentFocus: go.Spot.Left, segmentOffset: new go.Point(0, -12), segmentOrientation: go.Link.OrientMinus90 } ) ));
diagram.add( $(go.Part, "Graduated", $(go.Shape, { geometryString: "M0 0 A120 120 0 0 1 200 0" }), // an arc $(go.Shape, { geometryString: "M0 0 V10" }), $(go.TextBlock, { segmentOffset: new go.Point(0, 12), segmentOrientation: go.Link.OrientAlong } ) ));
diagram.add( $(go.Part, "Graduated", $(go.Shape, { geometryString: "M0 0 A120 120 0 0 1 200 0" }), // an arc $(go.Shape, { geometryString: "M0 0 V10" }), $(go.TextBlock, { segmentOffset: new go.Point(0, 12), segmentOrientation: go.Link.OrientAlong } ) ));
diagram.add( $(go.Part, "Graduated", $(go.Shape, { geometryString: "M0 0 V-400" }), $(go.Shape, { geometryString: "M0 0 V10", alignmentFocus: go.Spot.Top }), $(go.TextBlock, { alignmentFocus: go.Spot.Left, segmentOffset: new go.Point(0, 12) } ) ));
請(qǐng)注意幾何圖形如何從0變?yōu)?,-400,因?yàn)樨?fù)Y值在屏幕/頁(yè)面上更高。請(qǐng)注意,由于所有內(nèi)容都是相對(duì)于路徑的,因此刻度線和標(biāo)簽將在相反的一側(cè),因此我們還更改了alignmentFocus和segmentOffset以具有與上一個(gè)示例相反的值。
最后,如果方向是Link.OrientNone, Link.OrientAlong或Link.OrientUpright之一,則將考慮標(biāo)簽上指定的任何角度。對(duì)于“沿”和“垂直”,將在TextBlock的點(diǎn)將角度添加到主路徑的坡度。diagram.add( $(go.Part, "Spot", $(go.Panel, "Graduated", $(go.Shape, { geometryString: "M0 0 L100 0 100 100 L0 100" }), $(go.Shape, { geometryString: "M0 0 V10" }), $(go.TextBlock, { interval: 5, angle: 45, segmentOffset: new go.Point(0, 12) } ) ), $(go.TextBlock, "None") )); diagram.add( $(go.Part, "Spot", $(go.Panel, "Graduated", $(go.Shape, { geometryString: "M0 0 L100 0 100 100 L0 100" }), $(go.Shape, { geometryString: "M0 0 V10" }), $(go.TextBlock, { interval: 5, angle: 45, segmentOrientation: go.Link.OrientAlong, segmentOffset: new go.Point(0, 12) } ) ), $(go.TextBlock, "Along") )); diagram.add( $(go.Part, "Spot", $(go.Panel, "Graduated", $(go.Shape, { geometryString: "M0 0 L100 0 100 100 L0 100" }), $(go.Shape, { geometryString: "M0 0 V10" }), $(go.TextBlock, { interval: 5, angle: 45, segmentOrientation: go.Link.OrientUpright, segmentOffset: new go.Point(0, 12) } ) ), $(go.TextBlock, "Upright") ));
如果選擇“無”,則標(biāo)簽始終為45度。使用“沿”時(shí),標(biāo)簽始終比坡度高45度。使用“立式”時(shí),標(biāo)簽始終比坡度高45度,然后在必要時(shí)旋轉(zhuǎn)立式。
未完待續(xù)......
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自: