Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共7 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:辅助线应用求助

1楼
YUNSEL 发表于:2023/8/10 16:47:00

图片点击可在新窗口打开查看此主题相关图片如下:微信图片_20230810164130.png
图片点击可在新窗口打开查看


按论坛的例子,显示不出线条,这是什么原因呀?

代码如下:
'设定图表数据,因为只是演示,所以数据只用人工设置
Dim i均值 As Integer = e.Form.Controls("TextBox1").Value
Dim i上限 As Integer = e.Form.Controls("TextBox2").Value
Dim i下限 As Integer = e.Form.Controls("TextBox3").Value

'计算区间条形
Dim d1 As Date = "2023-7-20"
Dim d2 As Date = "2023-7-28"
Dim t As TimeSpan = d2 - d1
Dim 线长度 As Integer = t.TotalDays

'生成图表
Dim i As Integer
Dim Chart As WinForm.Chart = e.Form.Controls("Chart1") 
Dim C1Cha As C1.Win.C1Chart.C1Chart = Chart.BaseControl
Dim Series As WinForm.ChartSeries 
Chart.VisualEffect = True 
Chart.ChartType = ChartTypeEnum.Bar 
Chart.DataSource = "A" '设置绑定表

Chart.SeriesList.Clear() '清除图表原来的图系
Chart.AxisY.Min = 0 '指定Y轴的最小值
Chart.AxisY.Max = 150 '指定Y轴的最大值
Chart.AxisY.Major = 20 '主刻度间隔值为5000
Series = Chart.SeriesList.Add() '增加一个图系
Series.X.DataField = "日期" 'X轴绑定到月份列
Series.Y.DataField = "数值" 'Y轴绑定到数量列
Series.Text = "数值"
'Chart.AxisX.AnnoWithLabels = True
Chart.AxisX.DateType = True '明确指定X轴是日期型
Chart.AxisX.AnnoFormatString = "yyyy-MM-dd"
Chart.AxisX.AnnoRotation = 45 
Chart.LegendVisible = True 
Chart.LegendCompass = CompassEnum.South

'增加均值
Dim tl As C1.Win.C1Chart.TrendLine = C1Cha.ChartGroups(0).ChartData.TrendsList.AddNewTrendLine() 
tl.LineStyle.Color = Color.Gold '线条颜色 
tl.LineStyle.Thickness = 2 '线宽 
tl.LineStyle.Pattern = 0 '直线样式 0-5  
Dim zxb = New TbszLine()
zxb.SetXY(New PointF( - 0.5, i均值), New PointF(线长度, i均值))
zxb.SetText("均线")
tl.CustomTrendLine = zxb

'增加下限
tl = C1Cha.ChartGroups(0).ChartData.TrendsList.AddNewTrendLine() 
tl.LineStyle.Color = Color.red 
tl.LineStyle.Thickness = 2 
tl.LineStyle.Pattern = 2 
zxb = New TbszLine()
zxb.SetXY(New PointF( - 0.5, i下限), New PointF(线长度, i下限))
zxb.SetText("下限")
tl.CustomTrendLine = zxb

'增加上限
tl = C1Cha.ChartGroups(0).ChartData.TrendsList.AddNewTrendLine() 
tl.LineStyle.Color = Color.BurlyWood 
tl.LineStyle.Thickness = 2 
tl.LineStyle.Pattern = 2
zxb = New TbszLine()
zxb.SetXY(New PointF( - 0.5, i上限), New PointF(线长度, i上限))
zxb.SetText("上限")
tl.CustomTrendLine = zxb

示例项目:
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:柱状图标辅助线的实现.table


2楼
有点蓝 发表于:2023/8/10 17:02:00
不要使用绑定,改为遍历
3楼
YUNSEL 发表于:2023/8/10 17:37:00
改了还是不行

'设定图表数据,因为只是演示,所以数据只用人工设置
Dim i均值 As Integer = e.Form.Controls("TextBox1").Value
Dim i上限 As Integer = e.Form.Controls("TextBox2").Value
Dim i下限 As Integer = e.Form.Controls("TextBox3").Value

'计算区间条形
Dim d1 As Date = "2023-7-20"
Dim d2 As Date = "2023-7-28"
Dim t1 As TimeSpan = d2 - d1
Dim 线长度 As Integer = t1.TotalDays

'生成图表
'Dim i As Integer
Dim Chart As WinForm.Chart = e.Form.Controls("Chart1") 
Dim C1Cha As C1.Win.C1Chart.C1Chart = Chart.BaseControl
Dim Series As WinForm.ChartSeries 
Chart.VisualEffect = True 
Chart.ChartType = ChartTypeEnum.Bar 

Chart.SeriesList.Clear() '清除图表原来的图系
Chart.AxisY.Min = 0 '指定Y轴的最小值
Chart.AxisY.Max = 150 '指定Y轴的最大值
Chart.AxisY.Major = 20 '主刻度间隔值为5000

Dim t As Table = Tables("A") '定义一个变量t引用数据表
Series = Chart.SeriesList.Add() '增加一个图系
Series.Length = t.Rows.Count '图系的数据点数等于表的行数
For i As Integer = 0 To t.Rows.Count - 1 '指定每个数据点的位置
    Series.X(i) = t.Rows(i)("日期") '指定水平坐标
    Series.Y(i) = t.Rows(i)("数值") '指定垂直坐标
Next

Chart.AxisX.DateType = True '明确指定X轴是日期型
Chart.AxisX.AnnoFormatString = "yyyy-MM-dd"
Chart.AxisX.AnnoRotation = 45 
Chart.LegendVisible = True 
Chart.LegendCompass = CompassEnum.South

'增加均值
Dim tl As C1.Win.C1Chart.TrendLine = C1Cha.ChartGroups(0).ChartData.TrendsList.AddNewTrendLine() 
tl.LineStyle.Color = Color.Gold '线条颜色 
tl.LineStyle.Thickness = 2 '线宽 
tl.LineStyle.Pattern = 0 '直线样式 0-5  
Dim zxb = New TbszLine()
zxb.SetXY(New PointF( - 0.5, i均值), New PointF(线长度, i均值))
zxb.SetText("均线")
tl.CustomTrendLine = zxb

'增加下限
tl = C1Cha.ChartGroups(0).ChartData.TrendsList.AddNewTrendLine() 
tl.LineStyle.Color = Color.red 
tl.LineStyle.Thickness = 2 
tl.LineStyle.Pattern = 2 
zxb = New TbszLine()
zxb.SetXY(New PointF( - 0.5, i下限), New PointF(线长度, i下限))
zxb.SetText("下限")
tl.CustomTrendLine = zxb

'增加上限
tl = C1Cha.ChartGroups(0).ChartData.TrendsList.AddNewTrendLine() 
tl.LineStyle.Color = Color.BurlyWood 
tl.LineStyle.Thickness = 2 
tl.LineStyle.Pattern = 2
zxb = New TbszLine()
zxb.SetXY(New PointF( - 0.5, i上限), New PointF(线长度, i上限))
zxb.SetText("上限")
tl.CustomTrendLine = zxb
4楼
有点蓝 发表于:2023/8/10 17:46:00
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:柱状图标辅助线的实现.zip

5楼
YUNSEL 发表于:2023/8/10 18:45:00
谢谢
6楼
lgj716330 发表于:2024/10/7 11:18:00
如何将辅助线的值显示出来,而且只显示一个其中一个数据点的值
7楼
有点蓝 发表于:2024/10/7 20:40:00
只能显示到标题

zxb.SetText("均线" & i均值)
共7 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .05469 s, 4 queries.