url:
  pptxhandler/ppt:
    pattern: /$YAMLURL/ppt
    handler: PPTXHandler
    kwargs:
      headers:
        Content-Disposition: attachment; filename=output.pptx
      only: 2
      source: $YAMLPATH/examples-input.pptx    # Input file to load
      change-text:                    # First rule is called change-text
        Title 1:                      #   Find all shapes named "Title 1" in all slides
          text: Generated by Gramex   #   Replace their text

  pptxhandler/rules-example:
    pattern: /$YAMLURL/rules-example
    handler: PPTXHandler
    kwargs:
      headers:
        Content-Disposition: attachment; filename=rules-example.pptx
      only: 2
      source: $YAMLPATH/examples-input.pptx  # Common example file
      change:
        Title 1:                # Take the shape named "Title 1"
          text: New Title       # Replace its text with "New Title"

  pptxhandler/sales-example:
    pattern: /$YAMLURL/sales-example
    handler: PPTXHandler
    kwargs:
      headers:
        Content-Disposition: attachment; filename=sales-example.pptx
      only: 4
      source: $YAMLPATH/examples-input.pptx  # Common example file
      data:
        sales: {url: $YAMLPATH/sales.csv}
      change:
        data: data['sales'].groupby('Category')
        replicate: True
        sales-text:                # Take the shape named "sales-text"
          data: data[0]
          text: "Region {{ Category }} has sales of {{ Sales }}"

  pptxhandler/text-style:
    pattern: /$YAMLURL/text-style
    handler: PPTXHandler
    kwargs:
      headers:
        Content-Disposition: attachment; filename=text-style.pptx
      only: 5
      source: $YAMLPATH/examples-input.pptx  # Common example file
      rule-1:
        Title 1:
          text: New title
          style:
            color: '#ff0000'
        Text 1:
          text: New text
          style:
            color: '#00ff00'
            bold: True

  pptxhandler/text-xml-style:
    pattern: /$YAMLURL/text-xml-style
    handler: PPTXHandler
    kwargs:
      headers:
        Content-Disposition: attachment; filename=examples-text-xml-style.pptx
      only: 5
      source: $YAMLPATH/examples-input.pptx  # Common example file
      rule-1:
        Title 1:                # Take the shape named "Title 1"
          style:                # CSS like properties only for text
            color: '#ff00000'   # Text color will be red
            font-size: 12       # Settiing font-size
          text: "New Title <text color='#00ff00' bold='True'> Green Bold Text </text>"

  pptxhandler/group-example:
    pattern: /$YAMLURL/group-example
    handler: PPTXHandler
    kwargs:
      headers:
        Content-Disposition: attachment; filename=group-example.pptx
      only: 6
      source: $YAMLPATH/examples-input.pptx  # Common example file
      rule-1:
        Group 1:                        # Take the shape named "Group 1"
          Caption:                      # Find the shape named "Caption" inside it
            text: New caption           #   Change its text to "New caption"
          Picture:                      # Find the shape named "Picture" inside it
            image: $YAMLPATH/sample.png #   Replace the image with sample.png

  pptxhandler/group-args-example:
    pattern: /$YAMLURL/group-args-example
    handler: PPTXHandler
    kwargs:
      headers:
        Content-Disposition: attachment; filename=group-example.pptx
      only: 6
      source: $YAMLPATH/examples-input.pptx  # Common example file
      rule-1:
        Group 1:                        # Take the shape named "Group 1"
          Caption:                      # Find the shape named "Caption" inside it
            text: "{{ args['text'] }}"  #   Change its text to ?text=
          Picture:                      # Find the shape named "Picture" inside it
            image: $YAMLPATH/{{ args.get('image', 'sample') }}.png # Replace image with ?image=

  pptxhandler/css-example:
    pattern: /$YAMLURL/css-example
    handler: PPTXHandler
    kwargs:
      headers:
        Content-Disposition: attachment; filename=css-example.pptx
      only: 7
      source: $YAMLPATH/examples-input.pptx  # Common example file
      data:
        sales: {url: $YAMLPATH/sales.csv}
      rule-1:
        Rectangle 1:            # Take the shape named "Rectangle 1"
          css:
            data: data['sales']
            style:
              opacity: 0.5
              color: '#ff0000'
              fill: '#ffff00'
              stroke: '#ffff00'
              width:  200
              height: 200
              left: 50
              top: 100
              font-size: 14
              font-family: Georgia

  pptxhandler/replace-example:
    pattern: /$YAMLURL/replace-example
    handler: PPTXHandler
    kwargs:
      headers:
        Content-Disposition: attachment; filename=replace-example.pptx
      only: 8
      source: $YAMLPATH/examples-input.pptx  # Common example file
      change:
        Title 1:                        # Take the shape named "Title 1"
          replace:                      # Replace these keywords
            "Old": "New"                #   Old -> New
            "Title": "Heading"          #   Title -> Heading

  pptxhandler/image-example:
    pattern: /$YAMLURL/image-example
    handler: PPTXHandler
    kwargs:
      headers:
        Content-Disposition: attachment; filename=image-example.pptx
      only: 9
      source: $YAMLPATH/examples-input.pptx  # Common example file
      change:
        Picture 1:                      # Take the shape named "Picture 1"
          image: $YAMLPATH/sample.png     # Replace the image with sample.png

  pptxhandler/table-example:
    pattern: /$YAMLURL/table-example
    handler: PPTXHandler
    kwargs:
      headers:
        Content-Disposition: attachment; filename=table-example.pptx
      only: 10
      source: $YAMLPATH/examples-input.pptx  # Common example file
      data:
        table_data: {url: $YAMLPATH/sales.csv}
      new-edit-table:
        Table 1:                      # Shape Name
          table:
            data: data['table_data']
            style:                    # Common CSS for all the cells
              font-size: 14
              text-align: center
              italic: True
              underline: True
            columns:
              Sales:                  # Common CSS will get over-write for Sales column
                gradient: Reds
              Profit:
                gradient: Greens
              Growth:
                gradient: Blues
              Category:            # Common CSS will get over-write for GrossProfit column
                bold: False
                underline: False
                italic: False

  pptxhandler/replicate-example:
    pattern: /$YAMLURL/replicate-example
    handler: PPTXHandler
    kwargs:
      headers:
        Content-Disposition: attachment; filename=replicate-slide-example.pptx
      only: 11
      source: $YAMLPATH/examples-input.pptx  # Common example file
      data:
        replicate_data: {ext: json, url: $YAMLPATH/tweets.json}
      multiple-objects:               # Rule
        # Slide 1 will get replicated for all Categories (that is unique groups from groupby below),
        # if slide-number is defined else all slides will get replicated.
        data: data['replicate_data']
        replicate: True               # Entire rule will replicate for defined slides
        TextBox 1:
          text: "Tweet id is- {{id_str}}, Username:- {{ user['name'] }}"

  pptxhandler/stack-example:
    pattern: /$YAMLURL/stack-example
    handler: PPTXHandler
    kwargs:
      headers:
        Content-Disposition: attachment; filename=stack-example.pptx
      only: 12
      source: $YAMLPATH/examples-input.pptx     # Common example file
      data:
        sales: {url: $YAMLPATH/sales.csv}
      multiple-objects:                         # Rule
        TextBox 1:                              # Take the "TextBox 1" shape
          data: data['sales'].to_dict(orient='records')
          stack: vertical                     # Lay the images out horizontally to the right
          margin: 0.10                          # Should be between 0-1.
                                              # Percentage of margin from shape's height if stack is `vertical` else width.
          text: "{{ Category }}: {{ Sales }}" # Change the text using this template

  pptxhandler/template-example:
    pattern: /$YAMLURL/template-example
    handler: PPTXHandler
    kwargs:
      headers:
        Content-Disposition: attachment; filename=template-example.pptx
      only: 3
      source: $YAMLPATH/examples-input.pptx     # Common example file
      data:
        tweets: {ext: json, url: $YAMLPATH/tweets.json}
      change:
        Title 1:
          text: "Tweet from @{{ tweets[0]['user']['screen_name'] }}"

  pptxhandler/bullet-chart-example:
    pattern: /$YAMLURL/bullet-chart-example
    handler: PPTXHandler
    kwargs:
      headers:
        Content-Disposition: attachment; filename=bullet-chart-example.pptx
      only: 13
      source: $YAMLPATH/examples-input.pptx     # Common example file
      data:
        sales: {url: $YAMLPATH/sales.csv}
      draw-bullet:
        Bullet Rectangle Horizontal:
          bullet:
            data: data['sales']['Sales'].ix[0]
            poor: 0
            good: 30
            target: 100
            average: 60
            orient: horizontal
            gradient: 'Oranges'
            text:
              function: "lambda v: '%.1f' % v"
            style:
              font-size: 10     # Common css for all items(data, target, poor, good and average)
              data:             # Overwriting CSS for data
                font-size: 16
              target:             # Overwriting CSS for target
                text: False       # Overwriting text for text. Text will not be shown
                font-size: 12

        Bullet Rectangle Vertical:
          bullet:
            data: data['sales']['Sales'].ix[0]
            poor: 0
            good: 30
            target: 100
            average: 60
            orient: vertical
            gradient: 'Oranges'
            text:
              function: "lambda v: '%.1f' % v"
            style:
              font-size: 10     # Common css for all items(data, target, poor, good and average)
              data:             # Overwriting CSS for data
                font-size: 16
              target:             # Overwriting CSS for target
                text: False       # Overwriting text for text. Text will not be shown
                font-size: 12

  pptxhandler/calendarmap-example:
    pattern: /$YAMLURL/calendarmap-example
    handler: PPTXHandler
    kwargs:
      headers:
        Content-Disposition: attachment; filename=calendarmap-example.pptx
      only: 14
      source: $YAMLPATH/examples-input.pptx     # Common example file
      data:
        calendar: {url: $YAMLPATH/calendarmap.csv, parse_dates: ['date_time'], encoding: 'utf-8'}
      draw-calendar:
        Calendar Rectangle:
          calendarmap:
            data:
              function: data['calendar'].sort_values(by=['date_time']).set_index('date_time')['random_column']
            width: 35
            weekstart: 6
            label_top: 40
            label_left: 40
            text-color: '#000000'
            startdate: data.index[0]

  pptxhandler/heatgrid-example:
    pattern: /$YAMLURL/heatgrid-example
    handler: PPTXHandler
    kwargs:
      headers:
        Content-Disposition: attachment; filename=heatgrid-example.pptx
      only: 15
      source: $YAMLPATH/examples-input.pptx     # Common example file
      data:
        heatgrid: {url: $YAMLPATH/heatgrid.csv}
      draw-heatgrid:
        Heatgrid Rectangle:
          heatgrid:
            data: data['heatgrid']
            row: name
            column: hour
            value: value
            text: True
            left-margin: 0.20
            cell-width: 30
            cell-height: 30
            na-text: NA
            na-color: '#cccccc'
            style:
              gradient: RdYlGn
              font-size: 14
              margin: 10
              text-align: center

  pptxhandler/sankey-example:
    pattern: /$YAMLURL/sankey-example
    handler: PPTXHandler
    kwargs:
      headers:
        Content-Disposition: attachment; filename=sankey-example.pptx
      only: 16
      source: $YAMLPATH/examples-input.pptx     # Common example file
      data:
        sankey: {url: $YAMLPATH/sankey.csv}
      draw-sankey:
        Sankey Rectangle:
          sankey:
            data: data['sankey']
            sort: True
            text:
              function: "lambda g: g.sum().apply(lambda v: 'Node %s' % (v.name,), axis=1)"
            order:
              function: "lambda g: -g['D'].sum() / g['E'].sum()"
            color:
              function: "lambda g: _color.gradient(g['D'].sum() / g['E'].sum() * 2 - 1, _color.RdYlGn)"
            groups: ['A', 'B', 'C']

  pptxhandler/treemap-example:
    pattern: /$YAMLURL/treemap-example
    handler: PPTXHandler
    kwargs:
      headers:
        Content-Disposition: attachment; filename=treemap-example.pptx
      only: 17
      source: $YAMLPATH/examples-input.pptx     # Common example file
      data:
        treemap: {url: $YAMLPATH/treemap.csv}
      draw-treemap:
        Treemap Rectangle:
          treemap:
            data: data['treemap']
            keys: ['Family']
            values: "{'screentime': 'sum'}"
            size:
              function: "lambda v: v['screentime']"
            sort:
              function: "lambda v: v.sort_values(by=['screentime'], ascending=False)"
            color:
              function: "lambda v: _color.gradient(v['screentime'] / 50 - 3, _color.RdYlGn)"
            text:
              function: "lambda v: '{}'.format(v['Family'])"

  pptxhandler/grouped-bar-chart-example:
    pattern: /$YAMLURL/grouped-bar-chart-example
    handler: PPTXHandler
    kwargs:
      headers:
        Content-Disposition: attachment; filename=grouped-bar-chart-example.pptx
      only: 18
      source: $YAMLPATH/examples-input.pptx     # Common example file
      data:
        sales: {url: $YAMLPATH/sales.csv}
      edit-charts:                # Rule name
        Bar Chart Name:
          chart:
            data: data['sales'][['Category', 'Sales', 'Profit', 'Growth']]
            x: Category
            color:                # Define colors
              Sales: '#D73027'      # Specify color of sales line in 6-digit hex
              Profit: '#1A9850'     # Specify color of profit line
              Growth: '#cccccc'     # Specify color of profit line

  pptxhandler/column-bar-chart-example:
    pattern: /$YAMLURL/column-bar-chart-example
    handler: PPTXHandler
    kwargs:
      headers:
        Content-Disposition: attachment; filename=column-bar-chart-example.pptx
      only: 19
      source: $YAMLPATH/examples-input.pptx     # Common example file
      data:
        sales: {url: $YAMLPATH/sales.csv}
      edit-charts:                # Rule name
        Column Chart Name:
          chart:
            data: data['sales'][['Category', 'Sales', 'Profit', 'Growth']]
            x: Category
            color:                # Define colors
              Sales: '#D73027'      # Specify color of sales line in 6-digit hex
              Profit: '#1A9850'     # Specify color of profit line
              Growth: '#cccccc'     # Specify color of profit line

  pptxhandler/line-chart-example:
    pattern: /$YAMLURL/line-chart-example
    handler: PPTXHandler
    kwargs:
      headers:
        Content-Disposition: attachment; filename=line-chart-example.pptx
      only: 20
      source: $YAMLPATH/examples-input.pptx     # Common example file
      data:
        sales: {url: $YAMLPATH/sales.csv}
      edit-charts:                # Rule name
        Line Chart Name:
          chart:
            data: data['sales'][['Category', 'Sales', 'Profit', 'Growth']]
            x: Category
            color:                # Define colors
              Sales: '#D73027'      # Specify color of sales line in 6-digit hex
              Profit: '#1A9850'     # Specify color of profit line
              Growth: '#cccccc'     # Specify color of profit line

  pptxhandler/area-chart-example:
    pattern: /$YAMLURL/area-chart-example
    handler: PPTXHandler
    kwargs:
      headers:
        Content-Disposition: attachment; filename=area-chart-example.pptx
      only: 21
      source: $YAMLPATH/examples-input.pptx     # Common example file
      data:
        sales: {url: $YAMLPATH/sales.csv}
      edit-charts:                # Rule name
        Area Chart Name:          # Name of the chart shape. Case sensitive
          chart:
            data: data['sales'][['Category', 'Sales', 'Profit', 'Growth']]  # Use sales data
            x: Category           # The x-axis is the Category column. Other columns are Y-axis values
            color:                # Define colors
              Sales: '#D73027'      # Specify color of sales line in 6-digit hex
              Profit: '#1A9850'     # Specify color of profit line
              Growth: '#cccccc'     # Specify color of profit line
            opacity: 0.50         # Constant opacity for all lines

  pptxhandler/scatter-chart-example:
    pattern: /$YAMLURL/scatter-chart-example
    handler: PPTXHandler
    kwargs:
      headers:
        Content-Disposition: attachment; filename=scatter-chart-example.pptx
      only: 22
      source: $YAMLPATH/examples-input.pptx     # Common example file
      data:
        sales: {url: $YAMLPATH/sales.csv}
      edit-charts:                # Rule name
        Scatter Chart Name:
          chart:
            data: data['sales'][['Category', 'Sales', 'Profit', 'Growth']]
            x: Category
            color:                # Define colors
              Sales: '#D73027'      # Specify color of sales line in 6-digit hex
              Profit: '#1A9850'     # Specify color of profit line
              Growth: '#cccccc'     # Specify color of profit line

  pptxhandler/bubble-chart-example:
    pattern: /$YAMLURL/bubble-chart-example
    handler: PPTXHandler
    kwargs:
      headers:
        Content-Disposition: attachment; filename=bubble-chart-example.pptx
      only: 23
      source: $YAMLPATH/examples-input.pptx     # Common example file
      data:
        sales: {url: $YAMLPATH/sales.csv}
      edit-charts:                # Rule name
        Bubble Chart Name:
          chart:
            data: data['sales'][['Category', 'Sales', 'Profit', 'Growth']]
            x: Category
            size: Growth          # Optional: Column name from data for the size of the bubbles, if not defined default size will be 1
            color:                # Define colors
              Sales: '#D73027'      # Specify color of sales line in 6-digit hex
              Profit: '#1A9850'     # Specify color of profit line
              Growth: '#cccccc'     # Specify color of profit line

  pptxhandler/bubble-chart3d-example:
    pattern: /$YAMLURL/bubble-chart3d-example
    handler: PPTXHandler
    kwargs:
      headers:
        Content-Disposition: attachment; filename=bubble-chart3d-example.pptx
      only: 24
      source: $YAMLPATH/examples-input.pptx     # Common example file
      data:
        sales: {url: $YAMLPATH/sales.csv}
      edit-charts:                # Rule name
        Bubble Chart Name 3D:
          chart:
            data: data['sales'][['Category', 'Sales', 'Profit', 'Growth']]
            x: Category
            size: Growth          # Optional: Column name from data for the size of the bubbles, if not defined default size will be 1
            color:                # Define colors
              Sales: '#D73027'      # Specify color of sales line in 6-digit hex
              Profit: '#1A9850'     # Specify color of profit line
              Growth: '#cccccc'     # Specify color of profit line

  pptxhandler/radar-chart-example:
    pattern: /$YAMLURL/radar-chart-example
    handler: PPTXHandler
    kwargs:
      headers:
        Content-Disposition: attachment; filename=radar-chart-example.pptx
      only: 25
      source: $YAMLPATH/examples-input.pptx     # Common example file
      data:
        sales: {url: $YAMLPATH/sales.csv}
      edit-charts:                # Rule name
        Radar Chart Name:
          chart:
            data: data['sales'][['Category', 'Sales', 'Profit', 'Growth']]
            x: Category
            color:                # Define colors
              Sales: '#D73027'      # Specify color of sales line in 6-digit hex
              Profit: '#1A9850'     # Specify color of profit line
              Growth: '#cccccc'     # Specify color of profit line

  pptxhandler/donut-chart-example:
    pattern: /$YAMLURL/donut-chart-example
    handler: PPTXHandler
    kwargs:
      headers:
        Content-Disposition: attachment; filename=donut-chart-example.pptx
      only: 26
      source: $YAMLPATH/examples-input.pptx     # Common example file
      data:
        sales: {url: $YAMLPATH/sales.csv}
      edit-charts:                # Rule name
        Donut Chart Name:
          chart:
            data: data['sales'][['Category', 'Sales']]
            x: Category
            color:                  # Define colors
              FMCG: '#64A73B'
              Media: '#71685C'
              Banking: '#EB5605'
              Government: '#B9CA1A'
              Pharmaceutical: '#CCDDEA'

  pptxhandler/pie-chart-example:
    pattern: /$YAMLURL/pie-chart-example
    handler: PPTXHandler
    kwargs:
      headers:
        Content-Disposition: attachment; filename=pie-chart-example.pptx
      only: 27
      source: $YAMLPATH/examples-input.pptx     # Common example file
      data:
        sales: {url: $YAMLPATH/sales.csv}
      edit-charts:                # Rule name
        Pie Chart Name:
          chart:
            data: data['sales'][['Category', 'Sales']]
            x: Category
            color:                  # Define colors
              FMCG: '#64A73B'
              Media: '#71685C'
              Banking: '#EB5605'
              Government: '#B9CA1A'
              Pharmaceutical: '#CCDDEA'
