splunk / splunk-webframework-toolkit

The Splunk Web Framework Toolkit
Apache License 2.0
12 stars 13 forks source link

Grouping Sunburst with categoryFields when fields have spaces #6

Open hobbes3 opened 10 years ago

hobbes3 commented 10 years ago

How do I group fields with categoryField when the fields have spaces in them?

The documentation on the Toolkit app says:

Name: categoryFields Type: string Default: (can be a space-separated list) null (defaults to all) Description: A list of fields by which to group children of the root node. Each field essintially [sic] indicates the group of the next level in the tree.

I would think that an array of strings would make more sense here. For now, I'm just renaming all the fields to not use spaces.

itay commented 10 years ago

@hobbes3 you should be able to pass in an array of strings to the fields property. Does that not work?

hobbes3 commented 10 years ago

fields takes an array, but it still shows the last value node (Remaining), which I don't want.

Here is my code (I commented out the code to try it both ways):

    //var sunburst_search = '| `backlog_sanitization(backlog.2013.11, $months_ago$)` | stats sum(Remaining) AS Remaining BY "Sales Theater" "Sub-Theater" "Sales District" "Sub-District" | rename "Sales Theater" AS sales_theater "Sub-Theater" AS sub_theater "Sales District" AS sales_district "Sub-District" AS sub_district';
    var sunburst_search = '| `backlog_sanitization(backlog.2013.11, $months_ago$)` | stats sum(Remaining) AS Remaining BY "Sales Theater" "Sub-Theater" "Sales District" "Sub-District"';

    var SunburstSearch = new SearchManager({
        id: "sunburst_search",
        search: sunburst_search
    }, {tokens: true});

    var SunburstChart = new Sunburst({
        id: 'sunburst_chart',
        managerid: 'sunburst_search',
        el: $('#sunburst'),
        fields: ["Sales Theater", "Sub-Theater", "Sales District", "Sub-District"],
        //categoryFields: "sales_theater sub_theater sales_district sub_district",
        valueField: 'Remaining'
    }).render();
itay commented 10 years ago

And... I was wrong. This is a bug - you cannot currently pass in an array, thus hitting the limitation by @hobbes3 above. We will fix.