Stacking up multiple metrics


Hi, I have several metrics that add up to a total and I’d like to show them in stacked bars grouped by region for example. I found the stacked bars example in the documentation. However, it groups by 2 attributes (venuestate and venuecity). I need to group only by 1 attribute and stack several metrics. How can I do that?


hi, @pepe that scenario is well covered in the chartfactor toolkit, the only thing you need to do is pass to the visualization an array of metrics instead of only one metric. For example:

/* Configuration code for this widget */
let provider = cf.provider("Elastic Demo");
let source = provider.source('chicago_taxi_trips');
// Define metrics
let metrics = [
	cf.Metric("tolls", "sum"),
	cf.Metric("extras", "sum")
// Define attributes to group by
let group1 = cf.Attribute("pickup_district")
			.sort("desc", cf.Metric("fare", "sum"));

// Add metrics and groups to data source
let myData = source.groupby(group1)
// Define chart options
let myChart = myData.graph("Multimetric Bars")

Let me know if this answers your question. Best Regards.