以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  如何不建立窗口生成雷达图并保存为图片文件呢?  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=68487)

--  作者:kgdce
--  发布时间:2015/5/19 9:45:00
--  如何不建立窗口生成雷达图并保存为图片文件呢?
如何不建立窗口生成雷达图并保存为图片文件呢?
Dim c1Chart1 = Forms("窗口2").Controls("Chart1").BaseControl
c1Chart1.ChartGroups(0).ChartType = C1.Win.C1Chart.Chart2DTypeEnum.Radar
这段代码是在窗口中生成雷达图

Dim Chart As New ChartBuilder

Dim Series As WinForm.ChartSeries

Chart.DataTable = DataTables("选项")

Chart.SeriesList.Clear()

Chart.DataTable = DataTables("选项")
Chart.SeriesList.Clear()
Series = Chart.SeriesList.Add()
Series.X.DataField = "选项" & a1
Series.Y.DataField = "数量" & a1
Series.DataLabelText = "{#YVAL}"
Chart.ChartType = ChartTypeEnum.Bar \'设置图表类型
Chart.AxisX.AnnoWithLabels = True \'启用字符标示
Chart.VisualEffect = True \'加上这一行,让你的图表更漂亮
Chart.FooterText="各选项对应人数示意图"
Chart.PrintWidth = 100
Chart.PrintHeight = 140
Chart.BarClusterWidth = 60
Chart.SaveImage(ProjectPath & "Images\\xx" & a1 & ".wmf")

这段代码不在窗口生成图表,而是直接建立图表保存为图

问题:如何不利用窗口控件又能生成雷达图并保存为图片文件呢?


--  作者:Bin
--  发布时间:2015/5/19 9:51:00
--  
一定要利用窗口控件呢.
--  作者:kgdce
--  发布时间:2015/5/19 9:53:00
--  

代码:

Dim Chart As New ChartBuilder \'定义一个图表变量
Dim
Series As WinForm.ChartSeries \'定义一个图系变量
Chart.DataSource =
"统计表" \'设置绑定表
Chart.SeriesList.Clear()
\'清除图表原来的图系
Series = Chart.SeriesList.Add()
\'增加一个图系
Series.X.DataField =
"产品" \'X轴绑定到产品列
Series.Y.DataField =
"数量" \'Y轴绑定到数量列
Chart.PrintWidth =
140 \'宽度设为140毫米
Chart.PrintHeight =
100 \'高度设为100毫米
Chart.SaveImage(
"c:\\data\\test.bmp"
) \'将生成的图表保存为文件。

上面的代码可以直接在命令窗口执行,无须新建一个窗口并插入Char控件来测试

可是下面雷达图的例子的代码如何改才能有不建窗口而能生成图片呢?

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:图表_雷达图_例子.table



--  作者:Bin
--  发布时间:2015/5/19 10:05:00
--  
Dim c1Chart1 = Forms("窗口1").Controls("Chart1").BaseControl

改为

Dim c1Chart1 = new C1.Win.C1Chart.C1Chart

--  作者:kgdce
--  发布时间:2015/5/19 10:28:00
--  
请帮助在例子上修改测试一下
--  作者:Bin
--  发布时间:2015/5/19 10:40:00
--  

Dim c1Chart1 = new C1.Win.C1Chart.C1Chart



c1Chart1.ChartGroups(0).ChartType = C1.Win.C1Chart.Chart2DTypeEnum.Radar

c1Chart1.BackColor = Color.White

\' Setup the header and footer
c1Chart1.Header.Style.Font = New Font("Microsoft Sans Serif", 9, FontStyle.Bold)
c1Chart1.Header.Text = "Employment Candidate Review"
c1Chart1.Footer.Visible = False

\' Setup the legend
c1Chart1.Legend.Compass = C1.Win.C1Chart.CompassEnum.South
c1Chart1.Legend.Orientation = C1.Win.C1Chart.LegendOrientationEnum.Horizontal
c1Chart1.Legend.Visible = True

\' Setup the Axis X
Dim ax As C1.Win.C1Chart.Axis = c1Chart1.ChartArea.AxisX
ax.Font = New Font("Arial", 8)
ax.Thickness = 2
ax.AnnoMethod = C1.Win.C1Chart.AnnotationMethodEnum.ValueLabels
ax.GridMajor.Color = Color.DarkGray
ax.GridMajor.Pattern = C1.Win.C1Chart.LinePatternEnum.Solid
ax.GridMajor.Thickness = 2
ax.GridMajor.Visible = True

\' Setup the value labels
Dim vlbl As C1.Win.C1Chart.ValueLabel = ax.ValueLabels.AddNewLabel()
vlbl.NumericValue = 1
vlbl.Text = "Experience"

vlbl = ax.ValueLabels.AddNewLabel()
vlbl.NumericValue = 2
vlbl.Text = "Education"

vlbl = ax.ValueLabels.AddNewLabel()
vlbl.NumericValue = 3
vlbl.Text = "Communication"

vlbl = ax.ValueLabels.AddNewLabel()
vlbl.NumericValue = 4
vlbl.Text = "Friendliness"

vlbl = ax.ValueLabels.AddNewLabel()
vlbl.NumericValue = 5
vlbl.Text = "Presentation"

vlbl = ax.ValueLabels.AddNewLabel()
vlbl.NumericValue = 6
vlbl.Text = "Expression"

\' Setup the Axis Y
Dim ay As C1.Win.C1Chart.Axis = c1Chart1.ChartArea.AxisY
ay.Min = 0
ay.Max = 5
ay.UnitMinor = 0
ay.UnitMajor = 1
ay.Compass = C1.Win.C1Chart.CompassEnum.North

c1Chart1.UseAntiAliasedGraphics = True

\'输入具体数据生成图表

c1Chart1.ChartGroups(0).ChartType = C1.Win.C1Chart.Chart2DTypeEnum.Radar
Dim series As C1.Win.C1Chart.ChartDataSeriesCollection = c1Chart1.ChartGroups(0).ChartData.SeriesList
series.RemoveAll()

\' Fill the X array
Dim x As Integer() = CType(Array.CreateInstance(Gettype(Integer), 6), Integer())
Dim i As Integer
For i = 0 To x.Length - 1
    x(i) = i + 1
Next i

\' Add one series
Dim s As C1.Win.C1Chart.ChartDataSeries = series.AddNewSeries()
s.LineStyle.Color = Color.SeaGreen
s.LineStyle.Thickness = 2
s.LineStyle.Pattern = C1.Win.C1Chart.LinePatternEnum.Solid
s.SymbolStyle.Color = Color.FromArgb(90, Color.Lime)
s.SymbolStyle.Shape = C1.Win.C1Chart.SymbolShapeEnum.Tri
s.SymbolStyle.Size = 8
s.Label = "Michael Johnson"
s.Display = C1.Win.C1Chart.SeriesDisplayEnum.Show

Dim y() As Integer = {5, 3, 4, 5, 4, 2}
s.X.CopyDataIn(x)
s.Y.CopyDataIn(y)

\' Add one series
s = series.AddNewSeries()
s.LineStyle.Color = Color.Navy
s.LineStyle.Thickness = 2
s.LineStyle.Pattern = C1.Win.C1Chart.LinePatternEnum.Solid
s.SymbolStyle.Color = Color.FromArgb(90, Color.CornflowerBlue)
s.SymbolStyle.Shape = C1.Win.C1Chart.SymbolShapeEnum.Dot
s.SymbolStyle.Size = 8
s.Label = "Jim Hubbard"
s.Display = C1.Win.C1Chart.SeriesDisplayEnum.Show

y = New Integer() {3, 5, 3, 4, 3, 4}
s.X.CopyDataIn(x)
s.Y.CopyDataIn(y)

\' Add one series
s = series.AddNewSeries()
s.LineStyle.Color = Color.Chocolate
s.LineStyle.Thickness = 2
s.LineStyle.Pattern = C1.Win.C1Chart.LinePatternEnum.Dot
s.SymbolStyle.Color = Color.FromArgb(90, Color.Orange)
s.SymbolStyle.Shape = C1.Win.C1Chart.SymbolShapeEnum.Diamond
s.SymbolStyle.Size = 8
s.Label = "Larry Richardson"
s.Display = C1.Win.C1Chart.SeriesDisplayEnum.Show

y = New Integer() {5, 3, 2, 3, 4, 4}
s.X.CopyDataIn(x)
s.Y.CopyDataIn(y)
c1Chart1.SaveImage("1.jpg",System.Drawing.Imaging.ImageFormat.JPEG)

--  作者:wukangppbb
--  发布时间:2022/3/4 15:53:00
--  改了以后为啥无法允许了呢?
改了以后为啥无法允许了呢?