D3ChartView

The D3Chart view

Description

The D3Chart view displays data in a D3 chart. For examples of reusable D3 charts and components, see the NVD3 website.

Documentation

Library path

Properties

Name

Default value

Description

id Required. The unique ID for this control.
type"lineChart"Required. The type of chart to display:

data"preview"The type of data to retrieve from the search results
results | preview | events | summary | timeline ).
manageridnullThe ID of the search manager to bind this view to.
setupnullCreates the chart by running a function that takes a single "chart" argument. Set any additional chart-specific properties within this function. For information about the properties that are required for a given chart type, refer to the NVD3 website.
This property must be set using JavaScript.

Methods

Name

Description

renderDraws the view to the screen. Called only when you create the view manually in JavaScript.

Example (Django tag)

{% d3chart id="example-d3chart" managerid="example-search" type="pieChart" %}

Example (JavaScript)

<script>
    var deps = [
        "splunkjs/ready!",
        "splunkjs/mvc/d3chartview"
    ];
    require(deps, function(mvc) {
        var D3ChartView = require("splunkjs/mvc/d3chartview");

        // Instantiate components
        var donut_chart = new D3ChartView({
            id: "example-d3chart",
            managerid: "example-search",
            type: "pieChart",
            setup: function(chart){
                chart.color(d3.scale.category10().range());
                chart.donut(true);
            },
            el: $("#myd3chart")
        }).render();
    });
</script>