Public Class ChartletTobmp
    Private mychart As New VBprinter.Chartlet()
    Private Sub ChartletTobmp_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        '初始数据
        d1.RowCount = 6
        d1.Rows(0).Cells(0).Value = "张三"
        Randomize()
        For i As Integer = 1 To d1.ColumnCount - 1

            d1.Rows(0).Cells(i).Value = System.Math.Round(Rnd() * 100, 0)
        Next
        d1.Rows(1).Cells(0).Value = "李四"

        For i As Integer = 1 To d1.ColumnCount - 1

            d1.Rows(1).Cells(i).Value = System.Math.Round(Rnd() * 100, 0)
        Next
        d1.Rows(2).Cells(0).Value = "王五"
        For i As Integer = 1 To d1.ColumnCount - 1
            Randomize()
            d1.Rows(2).Cells(i).Value = System.Math.Round(Rnd() * 100, 0)
        Next
        d1.Rows(3).Cells(0).Value = "麻六"
        Randomize()
        For i As Integer = 1 To d1.ColumnCount - 1

            d1.Rows(3).Cells(i).Value = System.Math.Round(Rnd() * 100, 0)
        Next
        d1.Rows(4).Cells(0).Value = "小七"
        Randomize()
        For i As Integer = 1 To d1.ColumnCount - 1

            d1.Rows(4).Cells(i).Value = System.Math.Round(Rnd() * 100, 0)
        Next
     

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


        If RadioButton1.Checked = True Then
            ' mychart.ChartType = VBprinter.Chartlet.ChartTypes.Bar
            mychart.AppearanceStyle = VBprinter.Chartlet.AppearanceStyles.Bar_2D_Aurora_FlatCrystal_NoBorder
            mychart.ChartTitle.Text = "柱状图打印测试"
        ElseIf RadioButton2.Checked = True Then
            'mychart.ChartType = VBprinter.Chartlet.ChartTypes.Pie
            mychart.AppearanceStyle = VBprinter.Chartlet.AppearanceStyles.Pie_2D_Aurora_GlassCrystal_WhiteBorder
            mychart.ChartTitle.Text = "饼图打印测试"
        ElseIf RadioButton3.Checked = True Then
            'mychart.ChartType = VBprinter.Chartlet.ChartTypes.Line
            mychart.AppearanceStyle = VBprinter.Chartlet.AppearanceStyles.Line_3D_Aurora_GlassCrystalNone_NoBorder
            mychart.ChartTitle.Text = "折线图打印测试"
        End If
        If CheckBox1.Checked = True Then
            mychart.ChartTitle.Text = mychart.ChartTitle.Text & "(3D效果)"
            mychart.Dimension = VBprinter.Chartlet.ChartDimensions.Chart3D
        Else
            mychart.Dimension = VBprinter.Chartlet.ChartDimensions.Chart2D
        End If
        ' mychart.Fill.ColorStyle = VBprinter.Chartlet.ColorStyles.Breeze
        'mychart.Stroke.ColorStyle = VBprinter.Chartlet.ColorStyles.Breeze
        mychart.YLabels.UnitText = "分数"
        mychart.BindChartData(d1)
        ' mychart.Render(PictureBox1.CreateGraphics, New Rectangle(10, 10, PictureBox1.Width - 10, PictureBox1.Height - 10))
        Dim mybmp As New Bitmap(PictureBox1.Width, PictureBox1.Height)
        Dim myg As Graphics
        myg = Graphics.FromImage(mybmp)
        mychart.Render(myg, New Rectangle(10, 10, PictureBox1.Width - 10, PictureBox1.Height - 10))
        PictureBox1.Image = mybmp
        mybmp = Nothing

    End Sub

End Class