当折线图是多图系时,下面怎么改
Dim c1Chart1 = Chart.basecontrol
Dim lbls = c1Chart1.ChartLabels
For i As Integer = 0 To 12
Dim lbl As C1.Win.C1Chart.Label = lbls.LabelsCollection.AddNewLabel()
lbl.Text = Format(series.y(i), "0.00%")
lbl.AttachMethod = C1.Win.C1Chart.AttachMethodEnum.DataIndex
lbl.AttachMethodData.GroupIndex = 0
lbl.AttachMethodData.SeriesIndex = 0
lbl.AttachMethodData.PointIndex = i
If Series.Y(i) >= 0 Then
lbl.Style.ForeColor = Color.Black
Else
lbl.Style.ForeColor = Color.Red
End If
lbl.style.font = New font("宋体", 15)
lbl.Compass = LabelCompassEnum.North
lbl.Visible = True
Next
两条折线的时候,只有其中一条设置了百分比格式,另一条没成功。数据点的位置也不对,不知道如何调整
此主题相关图片如下:微信图片_20241031144258.png
[此贴子已经被作者于2024/10/31 14:49:55编辑过]
Dim Chart As WinForm.Chart
Dim Series As WinForm.ChartSeries
Dim t As Table = Tables("实销流水同期比较")
Chart = e.Form.Controls("Chart2")
Chart.ChartType = ChartTypeEnum.XYPlot
Chart.DataSource = "实销流水同期比较"
Chart.SeriesList.Clear()
Chart.AxisY.AnnoFormatString="00%"
For Each c As Col In t.Cols
If c.Name <> "月份" Then
Series = Chart.SeriesList.Add()
Series.Text = c.Name
Series.X.DataField = "月份"
Series.Y.DataField = c.Name
End If
Next
Chart.HeaderText = "销售增长情况"
Dim c1Chart1 = Chart.basecontrol
Dim lbls = c1Chart1.ChartLabels
For i As Integer = 0 To t.Rows.Count
Dim lbl As C1.Win.C1Chart.Label = lbls.LabelsCollection.AddNewLabel()
lbl.Text = Format(series.y(i), "0.00%")
lbl.AttachMethod = C1.Win.C1Chart.AttachMethodEnum.DataIndex
lbl.AttachMethodData.GroupIndex = 0
lbl.AttachMethodData.SeriesIndex = 0
lbl.AttachMethodData.PointIndex = i
If Series.Y(i) >= 0 Then '根据值进行判断,如果大于0则为黑色,如果小于0则为红色
lbl.Style.ForeColor = Color.Black
Else
lbl.Style.ForeColor = Color.Red
End If
lbl.style.font = New font("宋体", 15)
lbl.Compass = LabelCompassEnum.North
lbl.Visible = True
Next
Dim Chart As WinForm.Chart
Dim Series As WinForm.ChartSeries
Dim t As Table = Tables("实销流水同期比较")
Chart = e.Form.Controls("Chart2")
Chart.ChartType = ChartTypeEnum.XYPlot
Chart.DataSource = "实销流水同期比较"
Chart.SeriesList.Clear()
Chart.AxisY.AnnoFormatString = "00%"
Chart.HeaderText = "销售增长情况"
Dim c1Chart1 = Chart.basecontrol
Dim lbls = c1Chart1.ChartLabels
For Each c As Col In t.Cols
If c.Name <> "月份" Then
Series = Chart.SeriesList.Add()
Series.Text = c.Name
Series.X.DataField = "月份"
Series.Y.DataField = c.Name
For i As Integer = 0 To t.Rows.Count
Dim lbl As C1.Win.C1Chart.Label = lbls.LabelsCollection.AddNewLabel()
lbl.Text = Format(series.y(i), "0.00%")
lbl.AttachMethod = C1.Win.C1Chart.AttachMethodEnum.DataIndex
lbl.AttachMethodData.GroupIndex = 0
lbl.AttachMethodData.SeriesIndex = 0
lbl.AttachMethodData.PointIndex = i
If Series.Y(i) >= 0 Then '根据值进行判断,如果大于0则为黑色,如果小于0则为红色
lbl.Style.ForeColor = Color.Black
Else
lbl.Style.ForeColor = Color.Red
End If
lbl.style.font = New font("宋体", 15)
lbl.Compass = LabelCompassEnum.North
lbl.Visible = True
Next
End If
Next