AVG Bucket and split_chart

Hi there,
I've a vizualization that combines both AVG Bucket and a Split_chart. Only the data for the 1st row are displayed here, see the screenshot:


Here is its visState:

{
  "title": "AVG daily rooms count per user by day after registration",
  "type": "histogram",
  "params": {
    "type": "histogram",
    "grid": {
      "categoryLines": false,
      "valueAxis": "ValueAxis-1"
    },
    "categoryAxes": [
      {
        "id": "CategoryAxis-1",
        "type": "category",
        "position": "bottom",
        "show": true,
        "style": {},
        "scale": {
          "type": "linear"
        },
        "labels": {
          "show": true,
          "filter": true,
          "truncate": 100,
          "rotate": 0
        },
        "title": {}
      }
    ],
    "valueAxes": [
      {
        "id": "ValueAxis-1",
        "name": "LeftAxis-1",
        "type": "value",
        "position": "left",
        "show": true,
        "style": {},
        "scale": {
          "type": "linear",
          "mode": "normal"
        },
        "labels": {
          "show": true,
          "rotate": 0,
          "filter": false,
          "truncate": 100
        },
        "title": {
          "text": "Overall Average of Count"
        }
      }
    ],
    "seriesParams": [
      {
        "show": "true",
        "type": "histogram",
        "mode": "normal",
        "data": {
          "label": "Overall Average of Count",
          "id": "1"
        },
        "valueAxis": "ValueAxis-1",
        "drawLinesBetweenPoints": true,
        "showCircles": true
      }
    ],
    "addTooltip": true,
    "addLegend": true,
    "legendPosition": "top",
    "times": [],
    "addTimeMarker": true,
    "labels": {
      "show": true
    },
    "dimensions": {
      "x": {
        "accessor": 0,
        "format": {
          "id": "terms",
          "params": {
            "id": "number",
            "otherBucketLabel": "Other",
            "missingBucketLabel": "Missing"
          }
        },
        "params": {},
        "aggType": "terms"
      },
      "y": [
        {
          "accessor": 2,
          "format": {
            "id": "number"
          },
          "params": {},
          "aggType": "avg_bucket"
        }
      ],
      "series": [
        {
          "accessor": 1,
          "format": {
            "id": "date",
            "params": {
              "pattern": "YYYY-MM-DD"
            }
          },
          "params": {},
          "aggType": "date_histogram"
        }
      ]
    },
    "thresholdLine": {
      "show": false,
      "value": 10,
      "width": 1,
      "style": "full",
      "color": "#34130C"
    }
  },
  "aggs": [
    {
      "id": "2",
      "enabled": true,
      "type": "terms",
      "schema": "segment",
      "params": {
        "field": "days_after_registration",
        "orderBy": "_key",
        "order": "asc",
        "size": 9999,
        "otherBucket": true,
        "otherBucketLabel": "Other",
        "missingBucket": false,
        "missingBucketLabel": "Missing"
      }
    },
    {
      "id": "1",
      "enabled": true,
      "type": "avg_bucket",
      "schema": "metric",
      "params": {
        "customBucket": {
          "id": "1-bucket",
          "enabled": true,
          "type": "terms",
          "schema": {
            "group": "none",
            "title": "Bucket agg",
            "name": "bucketAgg",
            "aggFilter": [],
            "min": 0,
            "max": null,
            "editor": false,
            "params": []
          },
          "params": {
            "field": "player_id",
            "orderBy": "custom",
            "orderAgg": {
              "id": "1-bucket-orderAgg",
              "enabled": true,
              "type": "max",
              "schema": {
                "group": "none",
                "name": "orderAgg",
                "title": "Order Agg",
                "hideCustomLabel": true,
                "aggFilter": [
                  "!top_hits",
                  "!percentiles",
                  "!median",
                  "!std_dev",
                  "!derivative",
                  "!moving_avg",
                  "!serial_diff",
                  "!cumulative_sum",
                  "!avg_bucket",
                  "!max_bucket",
                  "!min_bucket",
                  "!sum_bucket"
                ],
                "min": 0,
                "max": null,
                "editor": false,
                "params": []
              },
              "params": {
                "field": "player_created_at"
              }
            },
            "order": "desc",
            "size": 9999,
            "otherBucket": true,
            "otherBucketLabel": "Other",
            "missingBucket": false,
            "missingBucketLabel": "Missing"
          }
        },
        "customMetric": {
          "id": "1-metric",
          "enabled": true,
          "type": "count",
          "schema": {
            "group": "none",
            "name": "metricAgg",
            "title": "Metric agg",
            "aggFilter": [
              "!top_hits",
              "!percentiles",
              "!percentile_ranks",
              "!median",
              "!std_dev",
              "!sum_bucket",
              "!avg_bucket",
              "!min_bucket",
              "!max_bucket",
              "!derivative",
              "!moving_avg",
              "!serial_diff",
              "!cumulative_sum",
              "!geo_bounds",
              "!geo_centroid"
            ],
            "min": 0,
            "max": null,
            "editor": false,
            "params": []
          },
          "params": {}
        }
      }
    },
    {
      "id": "3",
      "enabled": true,
      "type": "date_histogram",
      "schema": "split",
      "params": {
        "field": "player_created_at",
        "useNormalizedEsInterval": true,
        "interval": "d",
        "drop_partials": false,
        "min_doc_count": 1,
        "extended_bounds": {},
        "row": true
      }
    }
  ]
}

Is it a bug ?

Hi,

Thanks for pasting the visState. However, it's hard to understand what's happening without further context. Could you give us some steps on how to reproduce the issue? Please include Kibana version also.

Thanks for the response.
Here are screenshots of the visualization creating. The "split chart" is the cause of incorrect representing.



Here is the request:

{
  "aggs": {
    "2": {
      "terms": {
        "script": {
          "source": "if (doc['room_created_at'].size() != 0) {\r\n    if (doc['player_created_at'].size() != 0) {\r\n        Instant p = Instant.ofEpochMilli(doc['player_created_at'].value.millis);\r\n        Instant r = Instant.ofEpochMilli(doc['room_created_at'].value.millis);\r\n        LocalDateTime ztp = LocalDateTime.ofInstant(p, ZoneId.of('Europe/Kiev'));\r\n        LocalDateTime ztr = LocalDateTime.ofInstant(r, ZoneId.of('Europe/Kiev'));\r\n        LocalDate localp = ztp.toLocalDate();\r\n        LocalDate localr = ztr.toLocalDate();\r\n        long dayp = localp.toEpochDay();\r\n        long dayr = localr.toEpochDay();\r\n        return (dayr-dayp)\r\n    } else {\r\n        return (-1)\r\n    }\r\n} else {\r\n    return (-1)\r\n}",
          "lang": "painless"
        },
        "order": {
          "_key": "asc"
        },
        "value_type": "float",
        "size": 9999
      },
      "aggs": {
        "3": {
          "date_histogram": {
            "field": "player_created_at",
            "calendar_interval": "1d",
            "time_zone": "Europe/Kiev",
            "min_doc_count": 1
          },
          "aggs": {
            "1": {
              "avg_bucket": {
                "buckets_path": "1-bucket>_count"
              }
            },
            "1-bucket": {
              "terms": {
                "field": "player_id",
                "order": {
                  "1-bucket-orderAgg": "desc"
                },
                "size": 9999
              },
              "aggs": {
                "1-bucket-orderAgg": {
                  "max": {
                    "field": "player_created_at"
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "size": 0,
  "_source": {
    "excludes": []
  },
  "stored_fields": [
    "*"
  ],
  "script_fields": {
    "win_count": {
      "script": {
        "source": "if (doc['is_win'].size() == 0) {\r\n  return null\r\n} else {\r\n   if (doc['is_win'].value == true) {\r\n       return 1\r\n   } else {\r\n       return 0\r\n   }\r\n}",
        "lang": "painless"
      }
    },
    "win_not_count": {
      "script": {
        "source": "if (doc['is_win'].size() == 0) {\r\n  return null\r\n} else {\r\n   if (doc['is_win'].value == false) {\r\n       return 1\r\n   } else {\r\n       return 0\r\n   }\r\n}",
        "lang": "painless"
      }
    },
    "duration_in_min": {
      "script": {
        "source": "doc['room_duration'].value / 60",
        "lang": "painless"
      }
    },
    "days_after_registration": {
      "script": {
        "source": "if (doc['room_created_at'].size() != 0) {\r\n    if (doc['player_created_at'].size() != 0) {\r\n        Instant p = Instant.ofEpochMilli(doc['player_created_at'].value.millis);\r\n        Instant r = Instant.ofEpochMilli(doc['room_created_at'].value.millis);\r\n        LocalDateTime ztp = LocalDateTime.ofInstant(p, ZoneId.of('Europe/Kiev'));\r\n        LocalDateTime ztr = LocalDateTime.ofInstant(r, ZoneId.of('Europe/Kiev'));\r\n        LocalDate localp = ztp.toLocalDate();\r\n        LocalDate localr = ztr.toLocalDate();\r\n        long dayp = localp.toEpochDay();\r\n        long dayr = localr.toEpochDay();\r\n        return (dayr-dayp)\r\n    } else {\r\n        return (-1)\r\n    }\r\n} else {\r\n    return (-1)\r\n}",
        "lang": "painless"
      }
    },
    "kill_death_ratio": {
      "script": {
        "source": "if (doc['death'].value !=0) {\n    if (doc['kills'].value !=0) {\n        return doc['kills'].value/doc['death'].value\n    } else {\n        return doc['death'].value*-1\n    }\n} else {\n    return doc['kills'].value\n}",
        "lang": "painless"
      }
    }
  },
  "docvalue_fields": [
    {
      "field": "player_created_at",
      "format": "date_time"
    },
    {
      "field": "room_created_at",
      "format": "date_time"
    }
  ],
  "query": {
    "bool": {
      "must": [],
      "filter": [
        {
          "match_all": {}
        },
        {
          "range": {
            "room_created_at": {
              "format": "strict_date_optional_time",
              "gte": "2020-02-19T08:03:46.663Z",
              "lte": "2020-03-02T08:03:46.663Z"
            }
          }
        }
      ],
      "should": [],
      "must_not": []
    }
  }
}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.