ComponentDefinitions:
  DonutRing:
    DefinitionType: CanvasComponent
    Description: Progress ring drawn as SVG. No chart control, works with the Standard license.
    CustomProperties:
      Percent:
        PropertyKind: Input
        DisplayName: Percent
        DataType: Number
        RaiseOnReset: false
        Description: Value from 0 to 100.
        Default: =72
      CenterText:
        PropertyKind: Input
        DisplayName: CenterText
        DataType: Text
        RaiseOnReset: false
        Description: Text in the middle. Leave empty to show the rounded percent.
        Default: =""
      Caption:
        PropertyKind: Input
        DisplayName: Caption
        DataType: Text
        RaiseOnReset: false
        Description: Small line below the center text.
        Default: ="completed"
      BarColor:
        PropertyKind: Input
        DisplayName: BarColor
        DataType: Text
        RaiseOnReset: false
        Description: Hex color of the ring, for example #1F6FEB. SVG needs hex text, not a Color value.
        Default: ="#1F6FEB"
      TrackColor:
        PropertyKind: Input
        DisplayName: TrackColor
        DataType: Text
        RaiseOnReset: false
        Description: Hex color of the unfilled track.
        Default: ="#E4E8EC"
      Thickness:
        PropertyKind: Input
        DisplayName: Thickness
        DataType: Number
        RaiseOnReset: false
        Description: Ring thickness in percent of the diameter (2 to 30).
        Default: =10
      TextColor:
        PropertyKind: Input
        DisplayName: TextColor
        Description: TextColor
        DataType: Color
        RaiseOnReset: false
        Default: =RGBA(31, 41, 51, 1)
    Properties:
      Fill: =RGBA(0, 0, 0, 0)
      Height: =140
      Width: =140
    Children:
      - conRingRoot:
          Control: GroupContainer
          Variant: ManualLayout
          Properties:
            DropShadow: =DropShadow.None
            Fill: =RGBA(0, 0, 0, 0)
            Height: =DonutRing.Height
            Width: =DonutRing.Width
            X: =0
            Y: =0
          Children:
            - imgRingSvg:
                Control: Image
                Properties:
                  TabIndex: =0
                  AccessibleLabel: =Coalesce(DonutRing.CenterText, Text(Round(DonutRing.Percent, 0)) & "%") & " " & DonutRing.Caption
                  Height: =Min(DonutRing.Width, DonutRing.Height)
                  Image: |-
                    =With(
                        {
                            t: Max(2, Min(30, DonutRing.Thickness)),
                            p: Max(0, Min(100, DonutRing.Percent))
                        },
                        With(
                            {
                                r: 50 - t / 2,
                                c: 2 * Pi() * (50 - t / 2)
                            },
                            "data:image/svg+xml;utf8," & EncodeUrl(
                                "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'>" &
                                "<circle cx='50' cy='50' r='" & Text(r, "0.00", "en-US") & "' fill='none' stroke='" & DonutRing.TrackColor & "' stroke-width='" & Text(t, "0.00", "en-US") & "'/>" &
                                If(
                                    p > 0,
                                    "<circle cx='50' cy='50' r='" & Text(r, "0.00", "en-US") & "' fill='none' stroke='" & DonutRing.BarColor & "' stroke-width='" & Text(t, "0.00", "en-US") & "' stroke-linecap='round' stroke-dasharray='" & Text(c * p / 100, "0.00", "en-US") & " " & Text(c, "0.00", "en-US") & "' transform='rotate(-90 50 50)'/>",
                                    ""
                                ) &
                                "</svg>"
                            )
                        )
                    )
                  ImagePosition: =ImagePosition.Fit
                  Width: =Min(DonutRing.Width, DonutRing.Height)
                  X: =(DonutRing.Width - Min(DonutRing.Width, DonutRing.Height)) / 2
                  Y: =(DonutRing.Height - Min(DonutRing.Width, DonutRing.Height)) / 2
            - conRingCenter:
                Control: GroupContainer
                Variant: AutoLayout
                Properties:
                  DropShadow: =DropShadow.None
                  Height: =DonutRing.Height
                  LayoutAlignItems: =LayoutAlignItems.Center
                  LayoutDirection: =LayoutDirection.Vertical
                  LayoutGap: =0
                  LayoutJustifyContent: =LayoutJustifyContent.Center
                  Width: =DonutRing.Width
                  X: =0
                  Y: =0
                Children:
                  - txtRingValue:
                      Control: ModernText
                      Properties:
                        AccessibleLabel: =Coalesce(DonutRing.CenterText, Text(Round(DonutRing.Percent, 0)) & "%")
                        Align: =Align.Center
                        Color: =DonutRing.TextColor
                        Font: =Font.'Segoe UI'
                        FontWeight: =FontWeight.Semibold
                        Height: =Min(DonutRing.Width, DonutRing.Height) * 0.26
                        LayoutMinHeight: =0
                        LayoutMinWidth: =0
                        PaddingBottom: =0
                        PaddingLeft: =0
                        PaddingRight: =0
                        PaddingTop: =0
                        Size: =Max(10, Min(DonutRing.Width, DonutRing.Height) * 0.17)
                        Text: =Coalesce(DonutRing.CenterText, Text(Round(DonutRing.Percent, 0)) & "%")
                        VerticalAlign: =VerticalAlign.Middle
                        Width: =Min(DonutRing.Width, DonutRing.Height) * 0.6
                        Wrap: =false
                  - txtRingCaption:
                      Control: ModernText
                      Properties:
                        AccessibleLabel: =DonutRing.Caption
                        Align: =Align.Center
                        Color: =RGBA(95, 108, 123, 1)
                        Font: =Font.'Segoe UI'
                        Height: =Min(DonutRing.Width, DonutRing.Height) * 0.16
                        LayoutMinHeight: =0
                        LayoutMinWidth: =0
                        PaddingBottom: =0
                        PaddingLeft: =0
                        PaddingRight: =0
                        PaddingTop: =0
                        Size: =Max(8, Min(DonutRing.Width, DonutRing.Height) * 0.085)
                        Text: =DonutRing.Caption
                        VerticalAlign: =VerticalAlign.Middle
                        Visible: =!IsBlank(DonutRing.Caption)
                        Width: =Min(DonutRing.Width, DonutRing.Height) * 0.6
                        Wrap: =false
