Angular Funnel - legend

Configures the legend.

Selector: dxo-legend
Type:

Object

The legend is a component that helps a user identify funnel items. The legend contains several items, one per funnel item, each consisting of a colored marker and text showing the funnel item's argument.

DevExtreme HTML5 Javacript Funnel Legend

You can make the legend visible by setting the legend.visible property to true.

backgroundColor

Colors the legend's background.

Type:

String

Default Value: undefined

This property supports the following colors:

border

Configures the legend's border.

Selector: dxo-border
Type:

Object

columnCount

Arranges legend items into several columns.

Type:

Number

Default Value: 0

Use this property when the legend is oriented vertically. Otherwise, use rowCount.

NOTE
If you specify this property and, as a result, legend items do not fit into the available space, this property is ignored.
See Also

columnItemSpacing

Specifies an empty space between item columns in pixels.

Type:

Number

Default Value: 20

customizeHint

Specifies the hint that appears when a user hovers the mouse pointer over a legend item.

Type:

Function

Function parameters:
itemInfo:

Object

Information on the funnel item and its corresponding legend item.

Object structure:
Name Type Description
item

Funnel Item

The Item object.

text

String

The legend item's text.

Return Value:

String

The text to be displayed in the hint.

This property accepts a function that must return the required text. When implementing this function, use its parameter to access the information on the funnel item that corresponds to the legend item.

customizeItems

Allows you to change the order, text, and visibility of legend items.

Type:

Function

Function parameters:

Legend items before customizations.

Return Value:

Array<FunnelLegendItem>

Legend items after customizations.

The following code shows how to use the customizeItems function to sort legend items alphabetically:

jQuery
JavaScript
$(function() {
    $("#funnelContainer").dxFunnel({
        // ...
        legend: {
            customizeItems: function(items) {
                return items.sort(function(a, b) {
                    var itemA = a.text.toLowerCase();
                    var itemB = b.text.toLowerCase();
                    if(itemA < itemB) return -1;
                    if(itemA > itemB) return 1;
                    return 0;
                });
            }
        }
    });
});
Angular
app.component.html
app.component.ts
app.module.ts
<dx-funnel ... >
    <dxo-legend ...
        [customizeItems]="sortLegendItems">
    </dxo-legend>
</dx-funnel>
// ...
export class AppComponent {
    sortLegendItems(items) {
        return items.sort((a, b) => {
            let itemA = a.text.toLowerCase();
            let itemB = b.text.toLowerCase();
            if(itemA < itemB) return -1;
            if(itemA > itemB) return 1;
            return 0;
        });
    }
}
import { DxFunnelModule } from 'devextreme-angular';
// ...
@NgModule({
    imports: [
        // ...
        DxFunnelModule
    ],
    // ...
})
export class AppModule { }
Vue
App.vue
<template> 
    <DxFunnel ... >
        <DxLegend
            :customize-items="sortLegendItems"
        />
    </DxFunnel>
</template>

<script>
import { DxFunnel, DxLegend } from 'devextreme-vue/funnel';

export default {
    components: {
        DxFunnel,
        DxLegend
    },
    methods: {
        sortLegendItems(items) {
            return items.sort((a, b) => {
                let itemA = a.text.toLowerCase();
                let itemB = b.text.toLowerCase();
                if(itemA < itemB) return -1;
                if(itemA > itemB) return 1;
                return 0;
            });
        }
    }
}
</script>
React
App.js
import React from 'react';
import { Funnel, Legend } from 'devextreme-react/funnel';

class App extends React.Component {
    render() {
        return (
            <Funnel ... >
                <Legend ...
                    customizeItems={this.sortLegendItems}
                />
            </Funnel>
        );
    }

    sortLegendItems(items) {
        return items.sort((a, b) => {
            let itemA = a.text.toLowerCase();
            let itemB = b.text.toLowerCase();
            if(itemA < itemB) return -1;
            if(itemA > itemB) return 1;
            return 0;
        });
    }
}

export default App;
ASP.NET MVC Controls
Razor C#
@(Html.DevExtreme().Funnel()
    @* ... *@
    .Legend(l => l
        .CustomizeItems("sortLegendItems")
    )
)

<script type="text/javascript">
    function sortLegendItems (items) {
        return items.sort(function(a, b) {
            var itemA = a.text.toLowerCase();
            var itemB = b.text.toLowerCase();
            if(itemA < itemB) return -1;
            if(itemA > itemB) return 1;
            return 0;
        });
    }
</script>

customizeText

Customizes the text displayed by legend items.

Type:

Function

Function parameters:
itemInfo:

Object

Information on the funnel item and its corresponding legend item.

Object structure:
Name Type Description
item

Funnel Item

The Item object.

text

String

The legend item's original text.

Return Value:

String

The text for the legend item to display.

Cannot be used in themes.

NOTE
As an alternative to the function’s parameter you can use the this keyword.

font

Specifies the legend items' font properties.

Selector: dxo-font
Type:

Object

horizontalAlignment

Along with verticalAlignment, specifies the legend's position.

Type:

String

Default Value: 'right'
Accepted Values: 'center' | 'left' | 'right'

See Also

itemsAlignment

Aligns items in the last column or row (depending on the legend's orientation). Applies when legend items are not divided into columns or rows equally.

Type:

String

Default Value: undefined
Accepted Values: 'center' | 'left' | 'right'

itemTextPosition

Specifies the text's position relative to the marker in a legend item.

Type:

String

Default Value: undefined
Accepted Values: 'bottom' | 'left' | 'right' | 'top'

margin

Generates an empty space, measured in pixels, around the legend.

Selector: dxo-margin
Type:

Number

|

Object

Default Value: 10

When set to a number, this property applies to all the legend's sides. The object allows you to control each side individually.

DevExtreme Legend Margins

markerSize

Specifies the marker's size in a legend item in pixels.

Type:

Number

Default Value: 20

markerTemplate

Specifies an SVG element that serves as a custom legend item marker.

Type:

template

Template Data:

FunnelLegendItem

Information about a legend item.

Default Name: undefined

View Demo

NOTE
To export custom SVG content rendered by this template, parse the content in the svgToCanvas function. Refer to the Export Custom Markup demo for an example.

orientation

Arranges legend items vertically (in a column) or horizontally (in a row). The default value is "horizontal" if the legend.horizontalAlignment is "center". Otherwise, it is "vertical".

Type:

String

Default Value: undefined
Accepted Values: 'horizontal' | 'vertical'

See Also

paddingLeftRight

Generates an empty space, measured in pixels, between the legend's left/right border and its items.

Type:

Number

Default Value: 10

DevExtreme Legend Left-Right Padding

paddingTopBottom

Generates an empty space, measured in pixels, between the legend's top/bottom border and its items.

Type:

Number

Default Value: 10

DevExtreme Legend Top-Bottom Padding

rowCount

Arranges legend items in several rows.

Type:

Number

Default Value: 0

Use this property when the legend is oriented horizontally. Otherwise, use columnCount.

NOTE
If you specify this property and, as a result, legend items do not fit into the available space, this property is ignored.
See Also

rowItemSpacing

Specifies an empty space between item rows in pixels.

Type:

Number

Default Value: 8

title

Configures the legend title.

Selector: dxo-title
Type:

Object

|

String

DevExtreme PieChart: Legend Title

To specify only the title's text, assign it directly to this property. Otherwise, set this property to an object with the text and other fields specified.

The title can be accompanied by a subtitle. Assign it to the title.subtitle property.

verticalAlignment

Along with horizontalAlignment, specifies the legend's position.

Type:

String

Default Value: 'top'
Accepted Values: 'bottom' | 'top'

See Also

visible

Specifies the legend's visibility.

Type:

Boolean

Default Value: false