以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  图表Y轴显示重叠  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=133944)

--  作者:mxl810823
--  发布时间:2019/4/23 22:03:00
--  图表Y轴显示重叠
如图,代码如下,为什么多生成几次图表,Y轴显示的字就看不清楚了“Chart.SeriesList.Clear() ”这行代码没有用吗

With Tables("ftyptop")
    Dim q As Integer
图片点击可在新窗口打开查看此主题相关图片如下:818.png
图片点击可在新窗口打开查看
    q = .FindRow("[检测号] = \'" & e.Form.Controls("ComboBox1").value & "\'") \'从第一行开始查找
    If q >= 0 Then \'如果找到的话
        .Position = q \'定位到找到的行.
    End If
End With
Dim r As Row =  Tables("ftyptop").current


\'绘图
Dim Chart  As WinForm.Chart  \'定义一个图表变量
Dim Series As WinForm.ChartSeries \'定义一个图系变量

Dim t As Table =  Tables("FTYptop") \'定义一个变量t引用数据表
Chart = forms("ftyptop").controls("Chart1") \' 引用窗口中的图表
Chart.SeriesList.Clear() \'清除图表原来的图系
\'Chart.DataSource = "FTYptop" \'设置绑定表
Chart.ChartType = ChartTypeEnum.Bar
\'Chart.AxisY.Min = 0.98 \'指定Y轴的最小值
\'Chart.AxisY.Max = 1 \'指定Y轴的最大值
\'Chart.AxisY.Major = 0.002 \'主刻度间隔值为
Chart.SeriesList.Clear() \'清除图表原来的图系
Series = Chart.SeriesList.Add() \'增加一个图系

Series.Length = T.Cols.count-6 \'新增图系包括个数据点
For i As Integer = 0 To T.Cols.count-7 \'指定每个数据点的位置
    Series.X(i) = i \'指定水平坐标
    Series.Y(i) = r(i+6) \'垂直坐标成
    Chart.AxisX.SetValueLabel(i, t.cols(i+6).name) \'指定字符表示
Next
Chart.AxisX.AnnoRotation = - 45 \'X轴标示逆时针旋转45度
Series.DataLabelBackColor = Color.Blue \'蓝底
Series.DataLabelForeColor = Color.White \'白字

Dim c1Chart1 = Chart.basecontrol
Dim lbls = c1Chart1.ChartLabels
Dim v As Integer = 0
For i As Integer = 0 To T.Cols.count-6
    Dim lbl As C1.Win.C1Chart.Label = lbls.LabelsCollection.AddNewLabel()
    For Each c As Col In t.Cols
        Select Case c.name
            Case "检测号","良率","LCD型号V模组型号","入数","NG数","投产单号"
                
            Case Else
                v = v + r(c.name)
        End Select
    Next
    If series.y(i) > 0 Then
        lbl.Text = Format(series.y(i)/v, "0.0%")
    End If
    v = 0

    lbl.AttachMethod = C1.Win.C1Chart.AttachMethodEnum.DataIndex
    lbl.AttachMethodData.GroupIndex = 0
    lbl.AttachMethodData.SeriesIndex = 0
    lbl.AttachMethodData.PointIndex = i
    lbl.Style.ForeColor = Color.Red
    lbl.style.font = new font("仿宋体", 12)
    lbl.Compass = LabelCompassEnum.South
    lbl.Visible = True
    
Next

--  作者:有点蓝
--  发布时间:2019/4/23 22:38:00
--  

清除,加入代码,如

 

Chart.AxisX.ClearValueLabel


--  作者:mxl810823
--  发布时间:2019/4/24 10:26:00
--  
不行呢,关键是下面的代码生成的%比显示会重叠 怎么办??

Dim v As Integer = 0
For i As Integer = 0 To T.Cols.count-6
    Dim lbl As C1.Win.C1Chart.Label = lbls.LabelsCollection.AddNewLabel()
    For Each c As Col In t.Cols
        Select Case c.name
            Case "检测号","良率","LCD型号V模组型号","入数","NG数","投产单号"
                
            Case Else
                v = v + r(c.name)
        End Select
    Next
    If series.y(i) > 0 Then
        lbl.Text = Format(series.y(i)/v, "0.0%")
    End If
    v = 0

    lbl.AttachMethod = C1.Win.C1Chart.AttachMethodEnum.DataIndex
    lbl.AttachMethodData.GroupIndex = 0
    lbl.AttachMethodData.SeriesIndex = 0
    lbl.AttachMethodData.PointIndex = i
    lbl.Style.ForeColor = Color.Red
    lbl.style.font = new font("仿宋体", 10)
    lbl.Compass = LabelCompassEnum.South
    lbl.Visible = True
    
Next

--  作者:有点甜
--  发布时间:2019/4/24 12:23:00
--  

在循环外面,执行

 

lbls.LabelsCollection.clear

 


--  作者:mxl810823
--  发布时间:2019/4/24 15:24:00
--  
很好,果然解决了,只是你说的这些帮助里没找到呢,在哪里有相关的介绍???