⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 defaultvb.aspx.vb

📁 Telerik是很大的第三方软件制造商
💻 VB
字号:
Imports Telerik.QuickStart
Imports System.Data.OleDb
Imports Telerik.WebControls

Namespace Telerik.ChartExamplesVB.Programming.SettingValues
    Public Class DefaultVB
        Inherits XhtmlPage
        Private Shared maxSales As Integer = 5000
        Protected WithEvents Button1 As System.Web.UI.WebControls.Button
        Protected WithEvents btnSet As System.Web.UI.WebControls.Button
        Protected txtBoxSales As System.Web.UI.WebControls.TextBox
        Protected labelSales As System.Web.UI.WebControls.Label
        Protected WithEvents dropDownQuarter As System.Web.UI.WebControls.DropDownList
        Protected labelQuarter As System.Web.UI.WebControls.Label
        Protected RadChart1 As Telerik.WebControls.RadChart
        Private Shared profitRatio As Double = 0.1


        Private Sub InitComponents()
            dropDownQuarter.SelectedIndex = 0
            dropDownQuarter_SelectedIndexChanged(Nothing, System.EventArgs.Empty)
        End Sub 'InitComponents


        Private Sub GenRandomSales()
            Dim salesDataSeries As ChartSeries = RadChart1.GetChartSeries("SALES")

            If Not (salesDataSeries Is Nothing) Then
                Dim r As New Random()

                If salesDataSeries.Items.Count > 0 Then
                    Dim seriesItem As ChartSeriesItem
                    For Each seriesItem In salesDataSeries.Items
                        seriesItem.YValue = r.NextDouble() * maxSales
                    Next seriesItem
                Else
                    Dim i As Integer
                    For i = 0 To 3
                        salesDataSeries.AddItem((r.NextDouble() * maxSales))
                    Next i
                End If
            End If
        End Sub 'GenRandomSales


        Private Sub CalcProfit()
            Dim salesDataSeries As ChartSeries = RadChart1.GetChartSeries("SALES")
            Dim profitDataSeries As ChartSeries = RadChart1.GetChartSeries("Profit")

            If Not (salesDataSeries Is Nothing) AndAlso Not (profitDataSeries Is Nothing) Then
                profitDataSeries.Clear()

                Dim salesItem As ChartSeriesItem
                For Each salesItem In salesDataSeries.Items
                    profitDataSeries.AddItem((salesItem.YValue * profitRatio))
                Next salesItem
            End If
        End Sub 'CalcProfit


        Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
            If Not Page.IsPostBack Then
                InitRadChart()

                GenRandomSales()

                CalcProfit()

                InitComponents()
            End If
        End Sub 'Page_Load


        Private Sub InitRadChart()
            RadChart1.Clear()
            RadChart1.XAxis.DefaultItemFont = New Font("Arial", 10)
            RadChart1.XAxis.DefaultItemColor = Color.Black
            RadChart1.XAxis.AutoScale = False
            RadChart1.XAxis.AddItem("Q1")
            RadChart1.XAxis.AddItem("Q2")
            RadChart1.XAxis.AddItem("Q3")
            RadChart1.XAxis.AddItem("Q4")
            RadChart1.XAxis.LayoutStyle = ChartAxisLayoutStyle.Between

            Dim salesSeries As ChartSeries = RadChart1.CreateSeries("SALES", Color.Red, ChartSeriesType.Bar)
            salesSeries.Appearance.BorderColor = Color.Black
            salesSeries.Appearance.FillStyle = FillStyle.Solid
            salesSeries.ShowLabels = False

            Dim profitSeries As ChartSeries = RadChart1.CreateSeries("Profit", Color.Green, ChartSeriesType.Line)
            profitSeries.Appearance.FillStyle = FillStyle.Solid
            profitSeries.LabelAppearance.TextFont = New Font("Verdana", 6)
            profitSeries.LabelAppearance.TextColor = Color.Black
            profitSeries.LabelAppearance.Background.BorderColor = Color.Black
            profitSeries.LabelAppearance.Background.MainColor = Color.FromArgb(200, 255, 255, 255)
            profitSeries.LabelAppearance.Background.FillStyle = FillStyle.Solid
            profitSeries.DefaultLabel = "#Y{N2}"
            profitSeries.PointSize = 4
        End Sub 'InitRadChart

#Region "Web Form Designer generated code"

        Protected Overrides Sub OnInit(ByVal e As EventArgs)
            '
            ' CODEGEN: This call is required by the ASP.NET Web Form Designer.
            '
            InitializeComponent()
            MyBase.OnInit(e)
        End Sub 'OnInit


        '/		Required method for Designer support - do not modify
        '/		the contents of this method with the code editor.
        '/ </summary>
        Private Sub InitializeComponent()
        End Sub 'InitializeComponent

#End Region


        Private Sub dropDownQuarter_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dropDownQuarter.SelectedIndexChanged
            labelSales.Text = "Sales for " + dropDownQuarter.SelectedItem.Text

            Dim salesSeries As ChartSeries = RadChart1.GetChartSeries("SALES")

            If Not (salesSeries Is Nothing) Then
                txtBoxSales.Text = salesSeries(dropDownQuarter.SelectedIndex).YValue.ToString("##.##")
            End If
        End Sub 'dropDownQuarter_SelectedIndexChanged


        Private Sub btnSet_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSet.Click
            Dim salesSeries As ChartSeries = RadChart1.GetChartSeries("SALES")
            Dim profitSeries As ChartSeries = RadChart1.GetChartSeries("Profit")

            If Not (salesSeries Is Nothing) AndAlso Not (profitSeries Is Nothing) Then
                Try
                    Dim newValue As Double = Double.Parse(txtBoxSales.Text)

                    salesSeries(dropDownQuarter.SelectedIndex).YValue = newValue
                    profitSeries(dropDownQuarter.SelectedIndex).YValue = newValue * 0.1
                Catch
                End Try
            End If
        End Sub 'btnSet_Click


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

            CalcProfit()

            InitComponents()
        End Sub 'Button1_Click_1

    End Class
End Namespace

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -