I want to create a boxplot graph using plotly.js and elasticsearch.
Elasticsearch has an inbuild boxplot aggregation that returns this for each trace:
{
"aggregations": {
"load_time_boxplot": {
"min": 0.0,
"max": 990.0,
"q1": 165.0,
"q2": 445.0,
"q3": 725.0,
"lower": 0.0,
"upper": 990.0
}
}
}
Plotly has the following arguments for box plots. Some are obvious, but I dont know how to match up all of the elasticsearch boxplot aggregations into the plotly object.
q1
Parent: data[type=box]
Type: data array
Sets the Quartile 1 values. There should be as many items as the number of boxes desired.
median
Parent: data[type=box]
Type: data array
Sets the median values. There should be as many items as the number of boxes desired.
q3
Parent: data[type=box]
Type: data array
Sets the Quartile 3 values. There should be as many items as the number of boxes desired.
lowerfence
Parent: data[type=box]
Type: data array
Sets the lower fence values. There should be as many items as the number of boxes desired. This attribute has effect only under the q1/median/q3 signature. If `lowerfence` is not provided but a sample (in `y` or `x`) is set, we compute the lower as the last sample point below 1.5 times the IQR.
upperfence
Parent: data[type=box]
Type: data array
Sets the upper fence values. There should be as many items as the number of boxes desired. This attribute has effect only under the q1/median/q3 signature. If `upperfence` is not provided but a sample (in `y` or `x`) is set, we compute the lower as the last sample point above 1.5 times the IQR.
notchspan
Parent: data[type=box]
Type: data array
Sets the notch span from the boxes' `median` values. There should be as many items as the number of boxes desired. This attribute has effect only under the q1/median/q3 signature. If `notchspan` is not provided but a sample (in `y` or `x`) is set, we compute it as 1.57 " IQR / sqrt(N), where N is the sample size.
mean
Parent: data[type=box]
Type: data array
Sets the mean values. There should be as many items as the number of boxes desired. This attribute has effect only under the q1/median/q3 signature. If `mean` is not provided but a sample (in `y` or `x`) is set, we compute the mean for each box using the sample values.
sd
Parent: data[type=box]
Type: data array
Sets the standard deviation values. There should be as many items as the number of boxes desired. This attribute has effect only under the q1/median/q3 signature. If `sd` is not provided but a sample (in `y` or `x`) is set, we compute the standard deviation for each box using the sample values.
let polarityBuckets = i.aggregations.publisher.buckets;
let traces = {
sd: ???,
notchspan: ???,
mean: ???,
q1: polarityBuckets.map((e) => e.polarity["q1"]),
median: ???
q3: polarityBuckets.map((e) => e.polarity["q3"]),
lowerfence: polarityBuckets.map((e) => e.polarity["lower"]),
upperfence: polarityBuckets.map((e) => e.polarity["upper"]),
name: "test",
type: "box",
};
I dont even know if max and min exist. The plotly boxplot config doesnt show min or max options.
Maybe some of you know what i want and know the answer.
Thank you