0

ZedGraph コントロール (zgc) を使用して、個々の積み上げ棒グラフを作成し、下の画像に示すように、それらを 1 つの積み上げ列に表示しています。

私が抱えている問題は、リストボックス内の項目の数によって決定されるため、コントロールに表示されるペインの数を制御できないことです。コントロールのデフォルトの性質により、コントロール内に表示されるペインの数に応じてグラフ ペインの高さを変更できるようです。

zgc は、フォーム内で Dock=fill に設定されているパネル コントロール内で Dock=fill に設定されています。グラフ ペインを強制的に静的な高さにし、グラフ ペインの数がフォームの高さを超えると、必要に応じて垂直スクロール バーをパネルに表示したいと考えています。これを達成するにはどうすればよいですか?zgc を作成して設定するための私のコードは、画像の下に掲載されています。

ここに画像の説明を入力

Private Sub CreateGraph(ByVal dat As Date)

    Dim count As Integer = 0
    Dim master As MasterPane = zgc.MasterPane
    master.Fill = New Fill(Color.FromArgb(180, 180, 180), Color.FromArgb(180, 180, 180), 45.0F)
    master.PaneList.Clear()
    master.Title.IsVisible = True
    master.Title.Text = "Workload for " & dat.ToShortDateString()
    master.Margin.All = 10
    master.InnerPaneGap = 5
    master.IsCommonScaleFactor = False

    For Each mach As String In lbMach.Items
        rowCount = 0
        Dim myPaneT As New GraphPane(New Rectangle(10, 10, 10, 10), "", "Time in Minutes", mach)
        myPaneT.Fill.IsVisible = False
        myPaneT.Chart.Fill = New Fill(Color.White, Color.White, 45.0F)
        myPaneT.BaseDimension = 3.0F
        myPaneT.XAxis.Title.IsVisible = False
        myPaneT.XAxis.Scale.IsVisible = False

        myPaneT.XAxis.Scale.Min = 0
        myPaneT.XAxis.Scale.Max = (MeiSettings.WrkHrs * 60)
        myPaneT.Legend.IsVisible = True
        myPaneT.Border.IsVisible = False
        myPaneT.Title.IsVisible = False
        myPaneT.XAxis.MajorTic.IsOutside = False
        myPaneT.XAxis.MinorTic.IsOutside = False
        myPaneT.XAxis.MajorGrid.IsVisible = True
        myPaneT.XAxis.MinorGrid.IsVisible = True
        myPaneT.Margin.All = 1

        If count = lbMach.Items.Count - 1 Then
            myPaneT.XAxis.Title.IsVisible = True
            myPaneT.XAxis.Scale.IsVisible = True
            myPaneT.Margin.Bottom = 10
        End If

        If count > 0 Then
            myPaneT.YAxis.Scale.IsSkipLastLabel = True
        End If

        myPaneT.YAxis.MinSpace = 20
        myPaneT.Y2Axis.MinSpace = 20

        Dim dt As DataTable = ItemsByMachineDT(mach, dat)
        Dim myCurve As BarItem

        If dt.Rows.Count > 0 Then
            Dim profName As String = Nothing
            Dim timeDur() As Double
            For Each dr As DataRow In dt.Rows
                If profName = dr("PRO").ToString() Then
                    timeDur = {((Convert.ToDouble(dr("QTY")) / Convert.ToDouble(dr("MPM"))))}
                Else
                    timeDur = {((Convert.ToDouble(dr("QTY")) / Convert.ToDouble(dr("MPM")) + Convert.ToDouble(dr("Time"))))}
                End If

                myCurve = myPaneT.AddBar(dr("JOB").ToString & " - " & dr("PRO").ToString(), timeDur, Nothing, BarColor(rowCount))

                If MeiSettings.IsGradient = True Then
                    myCurve.Bar.Fill = New Fill(BarColor(rowCount), Color.White, BarColor(rowCount), 90.0F)
                Else
                    myCurve.Bar.Fill = New Fill(BarColor(rowCount), BarColor(rowCount), BarColor(rowCount), 90.0F)
                End If

                rowCount += 1
                profName = dr("PRO").ToString()
            Next
        End If

        myPaneT.YAxis.MajorTic.IsBetweenLabels = True
        myPaneT.YAxis.Type = AxisType.Text
        myPaneT.BarSettings.Type = BarType.Stack
        myPaneT.BarSettings.Base = BarBase.Y
        master.Add(myPaneT)
        count += 1
    Next

    zgc.IsShowPointValues = True

    Using g As Graphics = Me.CreateGraphics()
        master.SetLayout(g, PaneLayout.SingleColumn)
        master.AxisChange(g)
    End Using

End Sub
4

1 に答える 1

0

各 GraphPane の制御を取得するには:

    GraphPane temp = zgc.MasterPane.PaneList.ElementAt(ind); //ind => index of the graphpane in zedgraphcontrol

静的な高さ n 幅 ZedgraphControl を設定するには:

    zgc.Size = new Size(Width,Height);

スクロールバー ZedgraphControl の可視性を設定するには:

    zgc.IsShowHScrollBar = true;
    zgc.IsShowVScrollBar = true;
于 2013-02-27T19:10:23.980 に答える