Is it possible to create a pie chart from N different fields?

(John O'Conner) #1

I have 3 different durations (times between events) that make up 100% of the total time spent in a process. I want a pie chart to show a slice for each duration (3 slices). My documents have 3 fields, one for each duration.

Unfortunately, the Pie Chart visualization seems to allow summation or counts of a single document field, not different ones. Have I read this correctly? And if so, do you have suggestions for how I can use a pie chart in this situation?

Example docs:

  "id": 1,
  "duration1": 42.3,
  "duration2": 10.4,
  "duration3": 5.3
  "id": 2,
  "duration1": 35.2,
  "duration2": 8.4,
  "duration3": 3.3
  "id": 3,
  "duration1": 40.5,
  "duration2": 22.3,
  "duration3": 15.9

I've considered that maybe I can restructure these documents like this:

  "id": "1a",
  "durationType": "FOO",
  "duration": 42.3
  "id": "1b",
  "durationType": "BAR",
  "duration": 10.4
  "id": "1c",
  "durationType": "BAZ",
  "duration":  5.3

And this would allow me to use a single field duration for the pie chart while aggregating on a durationType filter. However, the downside of this method is that it separates the 3 durations across 3 separate sub-documents. This prevents me from filtering out all 3 docs when the duration of one is under or above a specific threshold. For example, I might need to filter out the 3 docs from the pie chart if the BAZ duration is under 6 seconds. And in this filtering situation, I'd want docs 1a, 1b, and 1c to not be included in the pie slices.

Any ideas?

(Vinod) #2

You could try a Split Slices on Filters Aggregation with the following three filters:

This should give you three Slices in the Pie Chart, each showing the Count of Documents which contain the respective fields: duration1, duration2 and duration3 (assuming that the Metrics chosen for Slice Size is Count)

(John O'Conner) #3

Thank you @vinodr for your suggestion. In this example, all documents will have all 3 fields, so your suggestion will show 3 equal slices every time I think.

Also, I'm hoping to show a pie chart showing slices of time amounts, not counts. So I think i need the slice size to be based on a time field, not count.

Thank you for reading and trying to help!

(system) #4

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