像Window任务管理器一样更改SeriesChartType颜色

时间:2014-03-13 20:10:57

标签: c# charts mschart

我想要更改我的Chart control SeriesChartType,但目前在更改所有图表的颜色效果后,包括Margins我最终会这样:

enter image description here

我正在寻找看起来像 Windows任务管理器

的东西

enter image description here

可以吗?

1 个答案:

答案 0 :(得分:1)

尝试自定义此类内容

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

    //Add an area chart to go under your line series
    Chart1.Series.Add("UnderSeries")
    Chart1.Series(0).BorderWidth = Chart1.Series(0).BorderWidth + 2
    Chart1.Series("UnderSeries").ChartType = SeriesChartType.Area

    //To create a semi transparent color, set alpha to 127. 
    //To create a transparent color, set alpha to any value from 1 through 254.
    Chart1.Series("UnderSeries").Color = Color.FromArgb(127, Color.Aqua)

    //place area chart over your line
    For Each pt As DataPoint In Chart1.Series(0).Points
        Chart1.Series("UnderSeries").Points.AddXY(pt.XValue, pt.YValues(0))
    Next

    //reorder series so line is above area chart
    Dim topSeries As Series = Chart1.Series(0)
    Chart1.Series.Remove(topSeries)
    Chart1.Series.Add(topSeries)

End sub

enter image description here