Azure / ibex-dashboard

Custom Analytics Dashboard for Microsoft Bot Framework and other applications as well
http://aka.ms/ibex
MIT License
169 stars 189 forks source link

[Question] Order BarChart by value's desc order #380

Open fms-santos opened 6 years ago

fms-santos commented 6 years ago

Hi,

I'm trying to build a custom dashboard with some analytics coming in from a chatbot I've built. My problem is that I can't figure out how to show a bar chart with the values in descending order.

The query is

  query: ({ granularity }) => `
     extend cslen=customDimensions.callstack_length, value=tostring(customDimensions.ID_Fornecedor) 
    | where name=='ChatbotFornecedores.InvoiceSearch' and (cslen == 0 or strlen(cslen) == 0) and strlen(value) > 0 
    | summarize faturas=count() by value
    | order by faturas desc`,
    filters: [{ dependency: "selectedFornecedores", queryProperty: "customDimensions.ID_Fornecedor" }],
      format: { type: "bars", args: { barsField: "value", valueField: "faturas", seriesField: "value" } },
  props: { nameKey: "values" }
}

The Data that shows up on the bar chart is exatly what I want:

[
  {
    "value": "1000478",
    "faturas": 7
  },
  {
    "value": "1020080",
    "faturas": 6
  },
  {
    "value": "1000968",
    "faturas": 4
  },
  {
    "value": "1000969",
    "faturas": 2
  }
]

But the bar chart itself shows up in this way: bar_chart

It orders by ID and not by the "faturas" count. I've played around with the props and args properties of the bar chart but I can't figure it out a way to solve this. I've also checked here Ibex-Components-BarChart and here Rechart-BarChartProps.

Thank you for your help!

morsh commented 6 years ago

Hi @fms-santos, Sorry but it seems you are right, according to the following code-1, code-2 (for 'format'), once the format sorts the values into the dictionary, the original order is destroyed, and the new order is the key name of the barsValue.

fms-santos commented 6 years ago

Ok, thank you @morsh . It would be more visually appealing to sort by the desc/asc order, at least in my use case ,)

morsh commented 6 years ago

I understand @fms-santos , but currently we're not actively working on the project. Nevertheless, we do receive and review PRs into the repo.