I have a dashboard with a Pie, including some filters to specify the Slices of the pie.
I want to build the Pie in canvas, but I don't know how. Can someone guide me a little bit, with some hints....how to get the filters for the slices in a canvas Pie.
I allready studied the online documentation, some example make it more clear.
Not sure what you mean for filters to specify the Slices of the pie but assuming you want to aggregate some index by a field and get the count of documents per field value and then filter out some values you want to hide, I think you can use the filterrows function in Canvas or maybe simply put a WHERE condition in your SQL clause.
In this screenshot I get from the flights sample data set a count of documents per Carrier and then in the expression editor I added a filterrows to only keep those for JetBeats and ES-Air
It's also important to note that you can use the pie visualization from the Dashboard directly on the Canvas. You can either save it to the visualization library, and use the Add from library button on the workpad, or create the pie chart again in Lens or Visualize by navigating to the editor directly from the Canvas top bar, then pressing Save and return once you've configured your pie chart.
This Canvas expression worked for me with the sample flights dataset
kibana
| selectFilter
| essql
query="SELECT Carrier, count(1) as count
FROM \"kibana_sample_data_flights\"
GROUP BY Carrier"
| mapColumn name="newCarrier" id="newCarrier" expression={
if condition={getCell Carrier | any {eq "JetBeats"} {eq "ES-Air"}}
then= "JetBeats and ES-Air"
else= { getCell Carrier }
}
| pointseries color="newCarrier" size="sum(count)"
| pie
| render
It uses mapColumn to define a new column in the data table that merges the rows for JetBeats and ES-Air. Then you also need to change the pointseries call to use the sum(count).
I don't know if this is off topic, but I do have a last challenge to solve, and I think I need the mapColumn for this but I do not exactly know if it is possible.
Let me tried to explain it:
I have a table, table A, inlcuding names, created with an ESSQL query from index A, I need to check if the names in that table are in another INDEX, INDEX B. And I want the result in a column in A. I'm stuck, I think I need to use the getCell function, that you used aswell and pipe it to an other ESSQL query to perform the search, but it is not working, I miss something. This is what I have so far:
| essql
query="SELECT target as Hosts FROM INDEXA WHERE \"@timestamp\" >= (TODAY() - INTERVAL 7 DAY)"
mapColumn name="Amount" id="Amount" expression={getCell Hosts | essql query='SELECT count(Bug) FROM "INDEXB" WHERE \"@timestamp\" >= (TODAY() - INTERVAL 7 DAY) AND target = Hosts'}
| render
I get the error:
[essql] > Unknown argument 'name' passed to function 'essql'
In the end I want add a couple columns like this and make a Pie out of it.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.