Excel Bar Graph - Distribution Line

I want to make a bar chart in excel that is simple with data analytics tools. If I want to do this automatically in vba, I can use this post to automatically get bins, and then set the control ranges.

The problem arises when I want to have a smooth distribution line. If I change the type of the chart to a smooth unfolding line, it will connect the column heights to each other, which will look like a blue line in this image:

bar chart

, , - (.. , ). , , , . - ? (- , R) , .

+4
1

( ), Trendline "", , , . Polynomial trend line

:

Sub AddPolynomialTrendline()
    Dim chrt As Chart
    Dim chrt_obj As ChartObject
    Dim trend As Trendline

    For Each chrt_obj In ActiveSheet.ChartObjects
    If chrt_obj.Name = "Chart1" Then
        With chrt_obj.Chart
            'the number after xlPolynomial is the order, which can be from 2 to 6
            Set trend = .SeriesCollection(1).Trendlines.Add(xlPolynomial, 6)
        End With
    End If
    Next chrt_obj
End Sub

, !

+1

Source: https://habr.com/ru/post/1674159/


All Articles