chartfx 画stack图

aspx.vb:

 

 Function CreateChart(ByVal dt As DataTable, ByVal title As String)
        Dim chart1 As New SoftwareFX.ChartFX.Internet.Server.Chart
        Dim table As DataTable
              chart1.AxisY.Gridlines = True
        chart1.Titles(0).Text = title
        chart1.AxisY.Gridlines = True
        chart1.Titles(0).Alignment = System.Drawing.StringAlignment.Center
        chart1.Titles(0).Font = New System.Drawing.Font("Times New Roman", 12, System.Drawing.FontStyle.Bold)
        chart1.Titles(0).TextColor = System.Drawing.Color.Brown

        chart1.Titles(0).Alignment = System.Drawing.StringAlignment.Center
        table = ChartTable(dt)
        chart1.DataSource = table
         Dim count As Integer = table.Columns.Count - 1
        Dim i As Integer
        For i = 0 To count
            If i = count - 2 Or i = (count - 1) Then
                chart1.Series(i).Gallery = SoftwareFX.ChartFX.Gallery.Lines      '折线
                chart1.Series(i).PointLabels = True
                chart1.Series(i).PointLabelAlign = SoftwareFX.ChartFX.LabelAlign.Top
                If i = (count - 1) Then
                    chart1.Series(i).Color = System.Drawing.Color.Red
                Else
                    chart1.Series(i).Color = System.Drawing.Color.YellowGreen
                End If

            Else
                chart1.Series(i).CylSides = Short.Parse("35")
                chart1.Series(i).PointLabels = False
                chart1.Series(i).Volume = Short.Parse("32")   '柱子大小
            End If
        Next
        Dim axis As SoftwareFX.ChartFX.Internet.Server.Axis = chart1.AxisY
        axis.Min = 0
        axis.Max = maxData
        axis.LabelsFormat.Format = SoftwareFX.ChartFX.AxisFormat.Number

        axis.LabelsFormat.Decimals = 0

        'chart1.HtmlTag = ".NET"


        chart1.Stacked = SoftwareFX.ChartFX.Stacked.Normal
        'chart1.AxisY.AutoScale = True
        'chart1.Scrollable = True    ' 横轴的scroll
        'chart1.AxisX.SetScrollView(20, 40)

        chart1.SerLegBox = True      '显示颜色标注show legend box

        Dim myBorder As SoftwareFX.ChartFX.Borders.ImageBorder       'chart的border s设置
        myBorder = New SoftwareFX.ChartFX.Borders.ImageBorder(SoftwareFX.ChartFX.Borders.ImageBorderType.Emboss)
        chart1.BackColor = System.Drawing.Color.Beige
        chart1.BorderObject = myBorder

        chart1.BackColor = System.Drawing.Color.AntiqueWhite   '背景颜色
        chart1.AxisY.Font = New System.Drawing.Font("Courier New", 9, System.Drawing.FontStyle.Regular)    'Y轴字体

        'chart1.PointLabels = True   ' 取消数据大小标注
        '   chart1.DataEditor = True
        If table.Rows.Count > 15 Then
            chart1.Width = Unit.Pixel(1200)
        Else
            chart1.Width = Unit.Pixel(800)
        End If

        chart1.Height = Unit.Pixel(300)
        chart1.Visible = True

        Panel1.Controls.Add(chart1)
    End Function

 

 Function ChartTable(ByVal dt As DataTable) As DataTable
        Dim table As New DataTable
        Dim dc As DataColumn
        Dim dr As DataRow
        Dim i, j As Integer
        dc = New DataColumn("date")
        table.Columns.Add(dc)
        For i = 0 To dt.Rows.Count - 1
            If String.Equals(dt.Rows(i).Item(2).ToString(), "DPPM") Or String.Equals(dt.Rows(i).Item(2).ToString(), "Overall  VLRR") Or String.Equals(dt.Rows(i).Item(2).ToString(), "Target(DPPM)") Then
                dc = New DataColumn(dt.Rows(i).Item(1).ToString(), GetType(Int64))
                table.Columns.Add(dc)
            End If
        Next
        For i = 3 To dt.Columns.Count - 1
            dr = table.NewRow
            dr("date") = dt.Columns(i).ColumnName
            For Each _dr As DataRow In dt.Rows
                For j = 1 To table.Columns.Count - 1
                    If String.Equals(_dr("NG").ToString(), "Qty") Then
                        Exit For
                    Else
                        If (String.Equals(_dr("defect").ToString(), table.Columns(j).ColumnName) And String.Equals(_dr("NG").ToString(), "DPPM")) Or (String.Equals(_dr("defect").ToString(), table.Columns(j).ColumnName) And String.Equals(_dr("NG").ToString(), "Overall  VLRR")) Or (String.Equals(_dr("defect").ToString(), table.Columns(j).ColumnName) And String.Equals(_dr("NG").ToString(), "Target(DPPM)")) Then
                            dr(table.Columns(j).ColumnName) = _dr(dt.Columns(i).ColumnName)
                        End If
                    End If
                Next
            Next
            table.Rows.Add(dr)
        Next
        Return table
    End Function

 

图片效果:

 stacked 图

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值