owc

Dim Agentstr As String = ""
Dim temp As String
Dim strOld As String = ""
Dim dataArr, ZBdataArr As String()
ReDim dataArr(1), ZBdataArr(1)
Dim tempstr As String = ""
Dim tempstr1 As String = ""
Dim tempstr2 As String = ""
Dim tempstr3 As String = ""

  For i = 0 To FAgentInfoDS.RecordCount - 1  

temp = FAgentInfoDS.GetFieldByName("AgentID_Alias").ToString
If strOld <> temp Then
AgentList.Add(temp)
strOld = temp
End If


tempstr = tempstr + String.Format("{0:n4}", ZBRate) + ControlChars.Tab
tempstr1 = tempstr1 + String.Format("{0:n4}", FZBRate) + ControlChars.Tab
tempstr2 = tempstr2 + CType(ZBCount, String) + ControlChars.Tab
tempstr3 = tempstr3 + CType(FZBCount, String) + ControlChars.Tab

next

tempstr = tempstr.Trim("")
tempstr1 = tempstr1.Trim("")
tempstr2 = tempstr2.Trim("")
tempstr3 = tempstr3.Trim("")
dataArr(0) = tempstr1
dataArr(1) = tempstr
ZBdataArr(0) = tempstr3
ZBdataArr(1) = tempstr2

ZBList.Clear()
ZBList.Add("非关键指标解答正确率")
ZBList.Add("关键指标解答正确率")
ZBListCont.Clear()
ZBListCont.Add("非关键指标出错数")
ZBListCont.Add("关键指标出错数")

'X轴标尺名称
For i = 0 To AgentList.Count - 1
Agentstr = Agentstr + AgentList(i).ToString + ControlChars.Tab
Next
Agentstr = Agentstr.Trim("")


'图形簇报表要多少组数据就添加多少个OWC11.ChSeries 对象
'创建ChartSpace对象来放置图表
Dim owcChartSpace As Microsoft.Office.Interop.Owc11.ChartSpace
Dim owcChart As Microsoft.Office.Interop.Owc11.ChChart
owcChartSpace = New Microsoft.Office.Interop.Owc11.ChartSpaceClass()

'将图形容器的边框颜色设置为白色
owcChartSpace.Border.Color = "White"


'在ChartSpace对象中添加图表,Add方法返回chart对象
owcChart = owcChartSpace.Charts.Add(0)

'指定图表的类型()
'owcChart.Type = Microsoft.Office.Interop.Owc11.ChartChartTypeEnum.chChartTypeColumnClustered
'显示标题
owcChart.HasTitle = True
'设置标题内容
owcChart.Title.Caption = "座席监控指标走势图形"
'设置标题字体的大小
owcChart.Title.Font.Size = 10
'设置标题为粗体
owcChart.Title.Font.Bold = True
'设置标题颜色为红色
owcChart.Title.Font.Color = "Red"


'指定图表是否需要图例
owcChart.HasLegend = True
'设置图例字体
'owcChart.Legend.Font.Size = 10
'设置图例位置为底端
'owcChart.Legend.Position = Microsoft.Office.Interop.Owc11.ChartLegendPositionEnum.chLegendPositionBottom


'初始化图形
'设置x轴标尺名称
owcChart.SetData(Microsoft.Office.Interop.Owc11.ChartDimensionsEnum.chDimCategories, CType(ChartSpecialDataSourcesEnum.chDataLiteral, Integer), Agentstr)


Dim setSales0, setSales1, setSales2, setSales3 As Microsoft.Office.Interop.Owc11.ChSeries

setSales0 = owcChart.SeriesCollection.Add(0)
setSales1 = owcChart.SeriesCollection.Add(0)
setSales2 = owcChart.SeriesCollection.Add(0)
setSales3 = owcChart.SeriesCollection.Add(0)
setSales0.Type = ChartChartTypeEnum.chChartTypeColumnClustered
setSales1.Type = ChartChartTypeEnum.chChartTypeColumnClustered
setSales2.Type = ChartChartTypeEnum.chChartTypeLineStacked
setSales3.Type = ChartChartTypeEnum.chChartTypeLineStacked
setSales2.Ungroup(True)
setSales3.Ungroup(True)
setSales3.Group(setSales2)
Dim MyAxis As Microsoft.Office.Interop.Owc11.ChAxis
MyAxis = owcChart.Axes.Add(setSales2.Scalings(Microsoft.Office.Interop.Owc11.ChartDimensionsEnum.chDimValues))

MyAxis.Position = Microsoft.Office.Interop.Owc11.ChartAxisPositionEnum.chAxisPositionRight
MyAxis.HasMinorGridlines = False
MyAxis.HasMajorGridlines = False
MyAxis.NumberFormat = "0.00%"
''serUnitSales.Type = ChartChartTypeEnum.chChartTypeLineStacked
''owcChart.SeriesCollection.Add(2).Type = ChartChartTypeEnum.chChartTypeLineStacked

 

''Dim MyAxis As Microsoft.Office.Interop.Owc11.ChAxis
''MyAxis = owcChart.Axes.Add(owcChart.SeriesCollection.Add(0).Scalings(Microsoft.Office.Interop.Owc11.ChartDimensionsEnum.chDimValues))

''MyAxis.Position = Microsoft.Office.Interop.Owc11.ChartAxisPositionEnum.chAxisPositionRight
''MyAxis.HasMinorGridlines = False
''MyAxis.NumberFormat = "0.00%"
''serUnitSales.Type = ChartChartTypeEnum.chChartTypeLineStacked
''owcChart.SeriesCollection.Add(2).Type = ChartChartTypeEnum.chChartTypeLineStacked
''owcChart.SeriesCollection.Add(0).Ungroup(True)
''owcChart.SeriesCollection.Add(0).Group(owcChart.SeriesCollection.Add(1))

setSales0.SetData(Microsoft.Office.Interop.Owc11.ChartDimensionsEnum.chDimSeriesNames, _
CType(Microsoft.Office.Interop.Owc11.ChartSpecialDataSourcesEnum.chDataLiteral, Integer), ZBListCont(0).ToString)

setSales0.SetData(Microsoft.Office.Interop.Owc11.ChartDimensionsEnum.chDimValues, CType(ChartSpecialDataSourcesEnum.chDataLiteral, Integer), ZBdataArr(0))
setSales1.SetData(Microsoft.Office.Interop.Owc11.ChartDimensionsEnum.chDimSeriesNames, _
CType(Microsoft.Office.Interop.Owc11.ChartSpecialDataSourcesEnum.chDataLiteral, Integer), ZBListCont(1).ToString)

setSales1.SetData(Microsoft.Office.Interop.Owc11.ChartDimensionsEnum.chDimValues, CType(ChartSpecialDataSourcesEnum.chDataLiteral, Integer), ZBdataArr(1))
setSales2.SetData(Microsoft.Office.Interop.Owc11.ChartDimensionsEnum.chDimSeriesNames, _
CType(Microsoft.Office.Interop.Owc11.ChartSpecialDataSourcesEnum.chDataLiteral, Integer), ZBList(0).ToString)
setSales2.SetData(Microsoft.Office.Interop.Owc11.ChartDimensionsEnum.chDimValues, CType(ChartSpecialDataSourcesEnum.chDataLiteral, Integer), dataArr(0))
setSales3.SetData(Microsoft.Office.Interop.Owc11.ChartDimensionsEnum.chDimSeriesNames, _
CType(Microsoft.Office.Interop.Owc11.ChartSpecialDataSourcesEnum.chDataLiteral, Integer), ZBList(1).ToString)
setSales3.SetData(Microsoft.Office.Interop.Owc11.ChartDimensionsEnum.chDimValues, CType(ChartSpecialDataSourcesEnum.chDataLiteral, Integer), dataArr(1))

Dim dl1 As Microsoft.Office.Interop.Owc11.ChDataLabels
dl1 = setSales2.DataLabelsCollection.Add()
dl1.HasValue = True
dl1 = setSales3.DataLabelsCollection.Add()
dl1.HasValue = True

 

'For i = 0 To ZBListCont.Count - 1
'owcChart.SeriesCollection.Add(1) = owcChart.SeriesCollection.Add(0)

'给定series的名字


'表示曲线上的单个数据标志


'将曲线簇的第一条柱设置为红色
'Point:代表图中的一部分,比如柱图的一条柱,饼图的一个扇区
'Interior:表示指定对象的内部
'setSales0.Points(0).Interior.Color = "Red"
'Next

 

'For i = 0 To ZBList.Count - 1
' Dim serUnitSales As Microsoft.Office.Interop.Owc11.ChSeries
' serUnitSales = owcChart.SeriesCollection.Add(0)
' serUnitSales.SetData(Microsoft.Office.Interop.Owc11.ChartDimensionsEnum.chDimSeriesNames, _
' CType(Microsoft.Office.Interop.Owc11.ChartSpecialDataSourcesEnum.chDataLiteral, Integer), ZBList(i).ToString)
' serUnitSales.SetData(Microsoft.Office.Interop.Owc11.ChartDimensionsEnum.chDimValues, CType(ChartSpecialDataSourcesEnum.chDataLiteral, Integer), dataArr(i))
' 'MyAxis.HasTitle = True
' 'MyAxis.Title.Caption = "报废率(%)"

' '给定series的名字
' serUnitSales.Type = ChartChartTypeEnum.chChartTypeLineStacked


' '表示曲线上的单个数据标志
' 'Dim dl1 As Microsoft.Office.Interop.Owc11.ChDataLabels
' 'dl1 = serUnitSales.DataLabelsCollection.Add()
' 'dl1.HasValue = True


' '将曲线簇的第一条柱设置为红色
' 'Point:代表图中的一部分,比如柱图的一条柱,饼图的一个扇区
' 'Interior:表示指定对象的内部
' 'setSales0.Points(0).Interior.Color = "Red"

'Next


'以GIF格式输出图表,大小为600*300,commend by luoym2009-12-14
If (File.Exists(strAbsolutePath)) Then '若存在相同的文件则删除
File.Delete(strAbsolutePath)
End If

owcChartSpace.ExportPicture(strAbsolutePath, "GIF", ImageWidth, ImageHeight) '输出成GIF文件并输出到指定路径。

Me.Image1.ImageUrl = "../ChartImages/" + Session("ChartFileName") '显示给图像控件

转载于:https://www.cnblogs.com/ouransun/archive/2012/09/29/2708388.html

已标记关键词 清除标记
表情包
插入表情
评论将由博主筛选后显示,对所有人可见 | 还能输入1000个字符 “速评一下”
©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页