翻譯|使用教程|編輯:楊鵬連|2020-08-25 11:14:38.577|閱讀 313 次
概述:本教程介紹如何創建分級面板,在“刻度”面板Panel.Graduated,平定期刻度/文字標簽沿主子圖的行程形狀???度面板可以視為顯示一系列值的比例尺。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
GoJS是一款功能強大,快速且輕量級的流程圖控件,可幫助你在JavaScript 和HTML5 Canvas程序中創建流程圖,且極大地簡化您的JavaScript / Canvas 程序。
刻度線外觀
刻度線相對于主要形狀路徑的出現由一些屬性控制:
設置graduatedStart和/或graduatedEnd僅允許沿主筆劃的一部分繪制刻度線:
diagram.add( $(go.Part, "Graduated", $(go.Shape, { geometryString: "M0 0 H400" }), $(go.Shape, { geometryString: "M0 0 V10", graduatedStart: .25, graduatedEnd: .75 }) ));
在這種情況下,現在僅在主體形狀的中部繪制刻度線。
設置alignmentFocus為go.Spot.Bottom將會使刻度線的底部與主筆劃對齊:
diagram.add( $(go.Part, "Graduated", $(go.Shape, { geometryString: "M0 0 H400" }), $(go.Shape, { geometryString: "M0 0 V10", alignmentFocus: go.Spot.Bottom }) ));
設置alignmentFocus為go.Spot.Center將會使刻度線在路徑中居中:
diagram.add( $(go.Part, "Graduated", $(go.Shape, { geometryString: "M0 0 H400" }), $(go.Shape, { geometryString: "M0 0 V10 M0 20 V30", alignmentFocus: go.Spot.Center }) ));
注意形狀的幾何形狀中的間隙。
設置segmentOffset標簽可以使它們在刻度線附近更具可讀性: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) } ) ));
請注意幾何圖形如何從0變為0,-400,因為負Y值在屏幕/頁面上更高。請注意,由于所有內容都是相對于路徑的,因此刻度線和標簽將在相反的一側,因此我們還更改了alignmentFocus和segmentOffset以具有與上一個示例相反的值。
最后,如果方向是Link.OrientNone, Link.OrientAlong或Link.OrientUpright之一,則將考慮標簽上指定的任何角度。對于“沿”和“垂直”,將在TextBlock的點將角度添加到主路徑的坡度。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") ));
如果選擇“無”,則標簽始終為45度。使用“沿”時,標簽始終比坡度高45度。使用“立式”時,標簽始終比坡度高45度,然后在必要時旋轉立式。
未完待續......
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自: