Skip to content

Commit 603f4fd

Browse files
committed
set radial range success
1 parent 0153ea1 commit 603f4fd

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

Data_science/DataMining/hierarchical-clustering/HCTreePlot/Dendrogram.vb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ Imports Microsoft.VisualBasic.Imaging.Drawing2D
5959
Imports Microsoft.VisualBasic.Imaging.Drawing2D.Colors
6060
Imports Microsoft.VisualBasic.Imaging.Driver
6161
Imports Microsoft.VisualBasic.MIME.Html.CSS
62+
Imports std = System.Math
6263

6364
Public Module Dendrogram
6465

@@ -106,7 +107,7 @@ Public Module Dendrogram
106107
Select Case layout
107108
Case Layouts.Vertical : Return New DendrogramPanelV2(hist, theme, colors, classinfo).Plot(size)
108109
Case Layouts.Horizon : Return New Horizon(hist, theme, colors, classinfo).Plot(size)
109-
Case Layouts.Radial : Return New RadialDendrogram(hist, theme, colors, classinfo).Plot(size)
110+
Case Layouts.Radial : Return New RadialDendrogram(hist, theme, colors, classinfo, maxRadial:=std.PI).Plot(size)
110111
Case Else
111112
Throw New NotImplementedException(layout.ToString)
112113
End Select

Data_science/DataMining/hierarchical-clustering/HCTreePlot/RadialDendrogram.vb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,20 @@ Imports std = System.Math
1414
''' </summary>
1515
Public Class RadialDendrogram : Inherits DendrogramPanel
1616

17+
ReadOnly maxRadial As Double = 2 * std.PI
18+
1719
Public Sub New(hist As Cluster, theme As Theme,
1820
Optional classes() As ColorClass = Nothing,
1921
Optional classinfo As Dictionary(Of String, String) = Nothing,
2022
Optional showAllLabels As Boolean = False,
2123
Optional showAllNodes As Boolean = False,
2224
Optional pointColor As String = "red",
2325
Optional showRuler As Boolean = True,
24-
Optional showLeafLabels As Boolean = True)
26+
Optional showLeafLabels As Boolean = True,
27+
Optional maxRadial As Double = 2 * std.PI)
2528

2629
MyBase.New(hist, theme, classes, classinfo, showAllLabels, showAllNodes, pointColor, showLeafLabels, showRuler)
30+
Me.maxRadial = maxRadial
2731
End Sub
2832

2933
Protected Overrides Sub PlotInternal(ByRef g As IGraphics, canvas As GraphicsRegion)
@@ -94,7 +98,7 @@ Public Class RadialDendrogram : Inherits DendrogramPanel
9498

9599
' 每个叶节点占用的角度 (弧度)
96100
' 修改为 2 * PI 以绘制完整的圆形树(原代码是 PI,即半圆)
97-
Dim unitAngle As Double = (2 * std.PI) / hist.Leafs
101+
Dim unitAngle As Double = maxRadial / hist.Leafs
98102

99103
' 开始递归绘制
100104
' 初始参数:当前节点=hist, 起始角度=0, 父节点位置=Nothing, 父节点半径=0
-5.97 KB
Loading

0 commit comments

Comments
 (0)