[
  {
    "type": "charts",
    "icon": "line-chart",
    "group": "capacity",
    "title": "Total vs Booked and Blocked Time",
    "code": "ccapacity_booked_vs_blocked_total",
    "panel": "google_chart_box",
    "config": {
      "source": "availability",
      "agg": {
        "filter": {
          "bool": {
            "must": [
              {"range": { "date": { "gte": "$ctrlChart.chart.start_date", "lte": "$ctrlChart.chart.end_date" } }  }
            ]
          }
        },
        "aggs": {
          "chart": {
            "date_histogram": {
              "field": "date",
              "interval": "$ctrlChart.chart.interval",
              "format": "dd-MM-YYY"
              },
            "aggs": {
              "chart1": {"avg": {"field": "total_time"} },
              "chart2": {"avg": {"field": "booked_time"} },
              "chart3": {"avg": {"field": "blocked_time"} }
            }
          }
        }
      },
      "form-schema": {
        "start_date":  {
          "title": "Start Date",
          "type": "string",
          "default": "now"
        },
        "end_date":  {
          "title": "End Date",
          "type": "string",
          "default": "now+2M"
        },
        "interval":  {
          "title": "Interval",
          "type": "string",
          "default": "day"
        }
      },
      "series": ["Total Time", "Booked Time", "Blocked Time"],
      "type": "chart chart-line",
      "options": {
        "legend":  {
          "display": true,
          "labels": {
              "fontColor": "rgb(99, 99, 132)"
          }
        }
      }
    }
  },
  {
    "type": "charts",
    "icon": "line-chart",
    "group": "capacity",
    "title": "Booked and Blocked Time as a %",
    "code": "capacity_blocked_booked_pct",
    "panel": "google_chart_box",
    "config": {
      "source": "availability",
      "agg": {
        "filter": {
          "bool": {
            "must": [
              {"range": { "date": { "gte": "$ctrlChart.chart.start_date", "lte": "$ctrlChart.chart.end_date" } }  }
            ]
          }
        },
        "aggs": {
          "chart": {
            "date_histogram": {
              "field": "date",
              "interval": "$ctrlChart.chart.interval",
              "format": "dd-MM-YYY"
              },
            "aggs": {
              "chart1": {"avg": {"field": "booked_pct"} },
              "chart2": {"avg": {"field": "blocked_pct"} }
            }
          }
        }
      },
      "form-schema": {
        "start_date":  {
          "title": "Start Date",
          "type": "string",
          "default": "now"
        },
        "end_date":  {
          "title": "End Date",
          "type": "string",
          "default": "now+2M"
        },
        "interval":  {
          "title": "Interval",
          "type": "string",
          "default": "day"
        }
      },
      "series": [ "Booked Time", "Blocked Time"],
      "type": "chart chart-line",
      "options": {
        "legend":  {
          "display": true,
          "labels": {
              "fontColor": "rgb(99, 99, 132)"
          }
        }
      }
    }
  },
  {
    "type": "charts",
    "icon": "line-chart",
    "group": "queue",
    "title": "Queue Lengths vs Staff Numbers",
    "code": "queue_length_vs_staff",
    "panel": "google_chart_box",
    "config": {
      "source": "availability",
      "agg": {
        "filter": {
          "bool": {
            "must": [
              {"range": { "datetime": { "gte": "$ctrlChart.chart.start_date", "lte": "$ctrlChart.chart.end_date" } }  },
              {"range": { "time": {"from": "480", "to": "1260"  }  }  }
            ]
          }
        },
        "aggs": {
          "chart": {
            "histogram":  {
              "field": "time",
              "interval": "$ctrlChart.chart.interval",
              "extended_bounds":  {
                    "min":  480,
                    "max":  1260
                }
              },
            "aggs": {
              "chart1": {"avg": {"field": "staff.total"} },
              "chart2": {"avg": {"field": "queues.avg.length"} }
            }
          }
        }
      },
      "form-schema": {
        "start_date":  {
          "title": "Start Date",
          "type": "relativedate",
          "default": "now-3M"
        },
        "end_date":  {
          "title": "End Date",
          "type": "relativedate",
          "default": "now"
        },
        "interval":  {
          "title": "Interval (mins)",
          "type": "select",
          "titleMap": {"60": "60 mins", "30": "30 mins", "20": "20 mins"},
          "default": "60"
        }
      },
      "series": ["Number of Staff", "Queue Length"],
      "type": "AreaChart",
      "labels-format": "time",
      "options": {
        "areaOpacity": 0.05,
        "aggregationTarget": "series",
        "hAxis":  {"minorGridlines":  {"count":  3}},
        "vAxis": {"minorGridlines":  {"count":  3}},
        "legend":  { "position":  "top", "maxLines":  3 }
      }
    }

  },
  {
    "type": "charts",
    "icon": "line-chart",
    "group": "queue",
    "title": "Staff Activity",
    "code": "queue_staff_activity",
    "panel": "google_chart_box",
    "config": {

      "source": "availability",
      "agg": {
        "filter": {
          "bool": {
            "must": [
              {"range": { "datetime": { "gte": "$ctrlChart.chart.start_date", "lte": "$ctrlChart.chart.end_date" } }  },
              {"range": { "time": {"from": "480", "to": "1260"  }  }  }
            ]
          }
        },
        "aggs": {
          "chart": {
            "histogram":  {
              "field": "time",
              "interval": "$ctrlChart.chart.interval",
              "extended_bounds":  {
                    "min":  480,
                    "max":  1260
                }
              },
            "aggs": {
              "chart1": {"avg": {"field": "staff.total"} },
              "chart2": {"avg": {"field": "staff.1"} },
              "chart3": {"avg": {"field": "staff.4"} }
            }
          }
        }
      },
      "form-schema": {
        "start_date":  {
          "title": "Start Date",
          "type": "relativedate",
          "default": "now-3M"
        },
        "end_date":  {
          "title": "End Date",
          "type": "relativedate",
          "default": "now"
        },
        "interval":  {
          "title": "Interval (mins)",
          "type": "select",
          "titleMap": {"60": "60 mins", "30": "30 mins", "20": "20 mins"},
          "default": "60"
        }
      },
      "series": ["Total Staff", "Waiting Staff", "Busy Staff"],
      "type": "AreaChart",
      "labels-format": "time",
       "options": {
        "areaOpacity": 0.05,
        "aggregationTarget": "series",
        "hAxis":  {"minorGridlines":  {"count":  3}},
        "vAxis": {"minorGridlines":  {"count":  3}},
        "legend":  { "position":  "top", "maxLines":  3 }
      }
    }

  },
  {
    "type": "charts",
    "icon": "line-chart",
    "group": "queue",
    "title": "Staff Numbers by Weekday, by hour",
    "code": "queue_staff_weekday_hour",
    "panel": "google_chart_box",
    "config": {

      "source": "availability",
      "agg": {
        "filter": {
          "bool": {
            "must": [
              {"range": { "datetime": { "gte": "$ctrlChart.chart.start_date", "lte": "$ctrlChart.chart.end_date" } }  },
              {"range": { "time": {"from": "480", "to": "1200"  }  }  }
            ]
          }
        },
        "aggs": {
          "chart": {
            "fiters": {
              "fiters": {
                "chart1": {"term": {"dow": 0}},
                "chart2": {"term": {"dow": 1}},
                "chart3": {"term": {"dow": 2}},
                "chart4": {"term": {"dow": 3}},
                "chart5": {"term": {"dow": 4}},
                "chart6": {"term": {"dow": 5}},
                "chart7": {"term": {"dow": 6}}
              }
            },
            "aggs": {
              "chart": {
                "histogram":  {
                  "field": "time",
                  "interval": "$ctrlChart.chart.interval",
                  "extended_bounds":  {
                        "min":  480,
                        "max":  1200
                  }
                },
                "aggs": {
                    "chart": {"avg": {"field": "staff.total"} }
                }
              }
            }
          }
        }
      },
      "form-schema": {
        "start_date":  {
          "title": "Start Date",
          "type": "relativedate",
          "default": "now-3M"
        },
        "end_date":  {
          "title": "End Date",
          "type": "relativedate",
          "default": "now"
        },
        "interval":  {
          "title": "Interval (mins)",
          "type": "select",
          "titleMap": {"60": "60 mins", "30": "30 mins", "20": "20 mins"},
          "default": "60"
        }
      },
      "series": ["Su","Mo","Tu", "We","Th","Fr","Sa"],
      "labels-format": "time",
      "type": "ColumnChart",
      "filters": ["service_id"],
      "options": {
        "hAxis":  {"minorGridlines":  {"count":  3}},
        "legend":  { "position":  "top", "maxLines":  3 },
        "bar":  { "groupWidth":  "75%" }
      }

    }

  },
  {
    "type": "charts",
    "icon": "line-chart",
    "group": "queue",
    "title": "Queue Lengths with Wait Time",
    "code": "queue_length_vs_wait",
    "panel": "google_chart_box",
    "config": {

      "source": "availability",
      "agg": {
        "filter": {
          "bool": {
            "must": [
              {"range": { "datetime": { "gte": "$ctrlChart.chart.start_date", "lte": "$ctrlChart.chart.end_date" } }  },
              {"range": { "time": {"from": "480", "to": "1260"  }  }  }
            ]
          }
        },
        "aggs": {
          "chart": {
            "histogram":  {
              "field": "time",
              "interval": "$ctrlChart.chart.interval",
              "extended_bounds":  {
                    "min":  480,
                    "max":  1260
                }
              },
            "aggs": {
              "chart1": {"avg": {"field": "queues.avg.wait_time"} },
              "chart2": {"avg": {"field": "queues.avg.length"} }
            }
          }
        }
      },
      "form-schema": {
        "start_date":  {
          "title": "Start Date",
          "type": "relativedate",
          "default": "now-3M"
        },
        "end_date":  {
          "title": "End Date",
          "type": "relativedate",
          "default": "now"
        },
        "interval":  {
          "title": "Interval (mins)",
          "type": "select",
          "titleMap": {"60": "60 mins", "30": "30 mins", "20": "20 mins"},
          "default": "60"
        }
      },
      "series": ["Wait Time", "Queue Length"],
      "type": "AreaChart",
      "labels-format": "time",
      "options": {
       "series":{
          "0":{"targetAxisIndex":0},
          "1":{"targetAxisIndex":1}
        },
        "areaOpacity": 0.05,
        "aggregationTarget": "series",
        "hAxis":  {"minorGridlines":  {"count":  3}},
        "vAxis": {"minorGridlines":  {"count":  3}},
        "legend":  { "position":  "top", "maxLines":  3 }
      }
    }
  },
  {
    "type": "charts",
    "icon": "line-chart",
    "group": "queue",
    "title": "Avg Wait length by Weekday, by hour",
    "code": "queue_wait_by_weekday_by_hour",
    "panel": "google_chart_box",
    "config": {
      "source": "availability",
      "agg": {
        "filter": {
          "bool": {
            "must": [
              {"range": { "datetime": { "gte": "$ctrlChart.chart.start_date", "lte": "$ctrlChart.chart.end_date" } }  },
              {"range": { "time": {"from": "480", "to": "1200"  }  }  }
            ]
          }
        },
        "aggs": {
          "chart": {
            "fiters": {
              "fiters": {
                "chart1": {"term": {"dow": 0}},
                "chart2": {"term": {"dow": 1}},
                "chart3": {"term": {"dow": 2}},
                "chart4": {"term": {"dow": 3}},
                "chart5": {"term": {"dow": 4}},
                "chart6": {"term": {"dow": 5}},
                "chart7": {"term": {"dow": 6}}
              }
            },
            "aggs": {
              "chart": {
                "histogram":  {
                  "field": "time",
                  "interval": "$ctrlChart.chart.interval",
                  "extended_bounds":  {
                        "min":  480,
                        "max":  1200
                  }
                },
                "aggs": {
                    "chart": {"avg": {"field": "queues.avg.wait_time"} }
                }
              }
            }
          }
        }
      },
      "form-schema": {
        "start_date":  {
          "title": "Start Date",
          "type": "relativedate",
          "default": "now-3M"
        },
        "end_date":  {
          "title": "End Date",
          "type": "relativedate",
          "default": "now"
        },
        "interval":  {
          "title": "Interval (mins)",
          "type": "select",
          "titleMap": {"60": "60 mins", "30": "30 mins", "20": "20 mins"},
          "default": "60"
        }
      },
      "series": ["Su","Mo","Tu", "We","Th","Fr","Sa"],
      "labels-format": "time",
      "type": "ColumnChart",
      "options": {
        "hAxis":  {"minorGridlines":  {"count":  3}},
        "legend":  { "position":  "top", "maxLines":  3 },
        "bar":  { "groupWidth":  "75%" }
      }
    }
  },
  {
    "type": "charts",
    "icon": "line-chart",
    "group": "queue",
    "title": "Delivery Time by Person",
    "code": "queue_delivery_time_by_person",
    "panel": "google_chart_box",
    "config": {
      "source": "booking",
      "agg": {
        "filter": {
          "range" : { "datetime" : { "gte": "$ctrlChart.chart.start_date","lte": "$ctrlChart.chart.end_date" } }
        },
        "aggs": {
          "chart" : {
            "filters" : {
              "fiters": "$chartCtrl.build_filter_hash('people', 'v%(index)d', '{\"term\": {\"person_id\": %(id)d}}')"
            },
            "aggs": {
              "chart1" : {"avg" : {"field": "listed_duration"} },
              "chart2" : {"avg" : {"field": "multi_status.being_seen_to_completed"} }
            }
          }
        }
      },
      "form-schema": {
        "start_date":  {
          "title": "Start Date",
          "type": "relativedate",
          "default": "now-3M"
        },
        "end_date":  {
          "title": "End Date",
          "type": "relativedate",
          "default": "now"
        }
      },
      "chart-labels": "build_filter_array('people', '&quot;%(name)s&quot;')",
      "series": ["Estimated Time", "Actual Time"],
      "type": "BarChart",
      "options": {
        "hAxis":  {"minorGridlines":  {"count":  3}},
        "legend":  { "position":  "top", "maxLines":  3 },
        "bar":  { "groupWidth":  "75%" },
        "isStacked": true
      }
    }
  },
  {
    "type": "charts",
    "icon": "line-chart",
    "group": "queue",
    "title": "Bookings by Person",
    "code": "queue_bookings_by_person",
    "panel": "google_chart_box",
    "config": {
      "source": "booking",
      "agg": {
        "filter": {
          "range": { "datetime": { "gte": "$ctrlChart.chart.start_date", "lte": "$ctrlChart.chart.end_date" } }
        },
        "aggs": {
          "chart": {
            "fiters": {
              "fiters": "$chartCtrl.build_filter_hash('people', 'v%(index)d', '{\"term\": {\"person_id \": %(id)d}}')"
            },
            "aggs": {
              "chart": {
                "terms" : { "field" : "service_id" }
              }
            }
          }
        }
      },
      "form-schema": {
        "start_date":  {
          "title": "Start Date",
          "type": "relativedate",
          "default": "now-3M"
        },
        "end_date":  {
          "title": "End Date",
          "type": "relativedate",
          "default": "now"
        }
      },
      "chart-labels": "$chartctrl.build_filter_array('people', '&quot;%(name)s&quot;')",
      "series": "$chartctrl.build_filter_array('services', '&quot;%(name)s (%(duration)d)&quot;')",
      "type": "ColumnChart",
      "options": {
        "hAxis":  {"minorGridlines":  {"count":  3}},
        "legend":  { "position":  "top", "maxLines":  3 },
        "bar":  { "groupWidth":  "75%" },
        "isStacked": true
      }
    }
  },
  {
    "type": "charts",
    "icon": "line-chart",
    "group": "booking",
    "title": "Bookings by Staff Member",
    "code": "queue_bookings_staff",
    "panel": "google_chart_box",
    "config": {
      "source": "booking",
      "agg": {
        "filter": {
          "range": { "datetime": { "gte": "$ctrlChart.chart.start_date", "lte": "$ctrlChart.chart.end_date" } }
        },
        "aggs": {
          "chart": {
            "fiters": {
              "fiters": "$chartctrl.build_filter_hash('people', 'chart%(index)d', '{\"term\": {\"person_id\": %(id)d}}')"
            },
            "aggs": {
              "chart": {
                "date_histogram": {
                  "field": "datetime",
                  "interval": "$ctrlChart.chart.interval",
                  "format": "dd-MM-YYY"
                }
              }
            }
          }
        }
      },
      "form-schema": {
        "start_date":  {
          "title": "Start Date",
          "type": "relativedate",
          "default": "now-3M"
        },
        "end_date":  {
          "title": "End Date",
          "type": "relativedate",
          "default": "now"
        },
        "interval":  {
          "title": "Interval",
          "type": "select",
          "titleMap": {"month": "Month", "week": "Week", "day": "Day"},
          "default": "week"
        }
      },
      "series": "$chartctrl.build_filter_array('people', '&quot;%(name)s&quot;')",
      "filters": ["service_id"],
      "type": "ColumnChart",
      "options": {
        "hAxis":  {"minorGridlines":  {"count":  3}},
        "legend":  { "position":  "top", "maxLines":  3 },
        "bar":  { "groupWidth":  "75%" },
        "isStacked": true
      }
    }
  },
  {
    "type": "charts",
    "icon": "line-chart",
    "group": "booking",
    "title": "Bookings by Service",
    "code": "queue_bookings_by_service",
    "panel": "google_chart_box",
    "config": {
      "source": "booking",
      "agg": {
        "filter": {
          "range": { "datetime": { "gte": "$ctrlChart.chart.start_date", "lte": "$ctrlChart.chart.end_date" } }
        },
        "aggs": {
          "chart": {
            "fiters": {
              "fiters": "$chartctrl.build_filter_hash('services', 'chart%(index)d', '{\"term\": {\"service_id\": %(id)d}}')"
            },
            "aggs": {
              "chart": {
                "date_histogram": {
                  "field": "datetime",
                  "interval": "$ctrlChart.chart.interval",
                  "format": "dd-MM-YYY"
                }
              }
            }
          }
        }
      },
      "form-schema": {
        "start_date":  {
          "title": "Start Date",
          "type": "relativedate",
          "default": "now-3M"
        },
        "end_date":  {
          "title": "End Date",
          "type": "relativedate",
          "default": "now"
        },
        "interval":  {
          "title": "Interval",
          "type": "select",
          "titleMap": {"month": "Month", "week": "Week", "day": "Day"},
          "default": "week"
        }
      },
      "series": "$chartctrl.build_filter_array('services', '&quot;%(name)s (%(duration)d)&quot;')",
      "filters": ["person_id"],
      "type": "ColumnChart",
      "options": {
        "hAxis":  {"minorGridlines":  {"count":  3}},
        "legend":  { "position":  "top", "maxLines":  3 },
        "bar":  { "groupWidth":  "75%" },
        "isStacked": true
      }

   }


  },
  {
    "type": "charts",
    "icon": "line-chart",
    "group": "booking",
    "title": "Bookings by Service %",
    "code": "queue_bookings_by_service_pct",
    "panel": "google_chart_box",
    "config": {
      "source": "booking",
      "agg": {
        "filter": {
          "range": { "datetime": { "gte": "$ctrlChart.chart.start_date", "lte": "$ctrlChart.chart.end_date" } }
        },
        "aggs": {
          "chart": {
            "fiters": {
              "fiters": "$chartctrl.build_filter_hash('services', 'chart%(index)d', '{\"term\": {\"service_id\": %(id)d}}')"
            },
            "aggs": {
              "chart": {
                "date_histogram": {
                  "field": "datetime",
                  "interval": "$ctrlChart.chart.interval",
                  "format": "dd-MM-YYY"
                }
              }
            }
          }
        }
      },
      "form-schema": {
        "start_date":  {
          "title": "Start Date",
          "type": "relativedate",
          "default": "now-3M"
        },
        "end_date":  {
          "title": "End Date",
          "type": "relativedate",
          "default": "now"
        },
        "interval":  {
          "title": "Interval",
          "type": "select",
          "titleMap": {"month": "Month", "week": "Week", "day": "Day"},
          "default": "week"
        }
      },
      "series": "$chartctrl.build_filter_array('services', '&quot;%(name)s (%(duration)d)&quot;')",
      "filters": ["person_id"],
      "type": "BarChart",
      "options": {
        "hAxis":  {"minorGridlines":  {"count":  3}},
        "legend":  { "position":  "top", "maxLines":  3 },
        "bar":  { "groupWidth":  "75%" },
        "isStacked": "percent"
      }
    }
  }
]