Hover

User Interaction

When a user presses or hovers over funnel items, they change their style to the one specified by the item.hoverStyle object.

jQuery
JavaScript
$(function() {
    $("#funnelContainer").dxFunnel({
        // ...
        item: {
            hoverStyle: {
                hatching: { direction: "left" }
            }
        }
    });
});
Angular
HTML
TypeScript
<dx-funnel ... >
    <dxo-item>
        <dxo-hover-style>
            <dxo-hatching direction="left"></dxo-hatching>
        </dxo-hover-style>
    </dxo-item>
</dx-funnel>
import { DxFunnelModule } from "devextreme-angular";
// ...
export class AppComponent {
    // ...
}
@NgModule({
    imports: [
        // ...
        DxFunnelModule
    ],
    // ...
})
Vue
App.vue
<template> 
    <DxFunnel ... >
        <DxItem ... >
            <DxHoverStyle>
                <DxHatching direction="left" />
            </DxHoverStyle>
        </DxItem>
    </DxFunnel>
</template>

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

export default {
    components: {
        DxFunnel,
        DxItem,
        DxHoverStyle,
        DxHatching
    }
}
</script>
React
App.js
import React from 'react';
import Funnel, {
    Item,
    HoverStyle,
    Hatching
} from 'devextreme-react/funnel';

class App extends React.Component {
    render() {
        return (
            <Funnel ... >
                <Item ... >
                    <HoverStyle>
                        <Hatching direction="left" />
                    </HoverStyle>
                </Item>
            </Funnel>
        );
    }
}

export default App;

If you need to disable this feature, set the hoverEnabled option to false.

jQuery
JavaScript
$(function() {
    $("#funnelContainer").dxFunnel({
        // ...
        hoverEnabled: false
    });
});
Angular
HTML
TypeScript
<dx-funnel ...
    [hoverEnabled]="false">
</dx-funnel>
import { DxFunnelModule } from "devextreme-angular";
// ...
export class AppComponent {
    // ...
}
@NgModule({
    imports: [
        // ...
        DxFunnelModule
    ],
    // ...
})
Vue
App.vue
<template> 
    <DxFunnel :hover-enabled="false" />
</template>

<script>
import DxFunnel from 'devextreme-vue/funnel';

export default {
    components: {
        DxFunnel
    }
}
</script>
React
App.js
import React from 'react';
import Funnel from 'devextreme-react/funnel';

class App extends React.Component {
    render() {
        return (
            <Funnel hoverEnabled={false} />
        );
    }
}

export default App;

API

You can change a funnel item's hover state by passing true or false to the item's hover(state) method. To check whether the funnel item is currently hovered over, call its isHovered() method.

jQuery
JavaScript
var toggleItemHoverState = function (item) {
    item.hover(!item.isHovered());
}
Angular
TypeScript
import { DxFunnelModule } from "devextreme-angular";
// ...
export class AppComponent {
    toggleItemHoverState (item) {
        item.hover(!item.isHovered());
    }
}
@NgModule({
    imports: [
        // ...
        DxFunnelModule
    ],
    // ...
})
Vue
App.vue
<script>
export default {
    methods: {
        toggleItemHoverState (item) {
            item.hover(!item.isHovered());
        }
    }
}
</script>
React
App.js
import React from 'react';

class App extends React.Component {
    toggleItemHoverState (item) {
        item.hover(!item.isHovered());
    }
}

export default App;
See Also

Events

When a funnel item's hover state is being changed, the Funnel raises the hoverChanged event that you can handle with a function. If the handling function is not going to be changed during the lifetime of the widget, assign it to the onHoverChanged option when you configure the widget. To check whether the pointer entered or left a funnel item, call the item's isHovered() method.

jQuery
JavaScript
$(function() {
    $("#funnelContainer").dxFunnel({
        // ...
        onHoverChanged: function (e) {
            if (e.item.isHovered()) {
                // Commands to execute when the pointer enters the item
            } else {
                // Commands to execute when the pointer leaves the item
            }
        }
    });
});
Angular
HTML
TypeScript
<dx-funnel ...
    (onHoverChanged)="onHoverChanged($event)">
</dx-funnel>
import { DxFunnelModule } from "devextreme-angular";
// ...
export class AppComponent {
    onHoverChanged (e) {
        if (e.item.isHovered()) {
            // Commands to execute when the pointer enters the item
        } else {
            // Commands to execute when the pointer leaves the item
        }
    };
}
@NgModule({
    imports: [
        // ...
        DxFunnelModule
    ],
    // ...
})
Vue
App.vue
<template> 
    <DxFunnel
        @hover-changed="onHoverChanged"
    />
</template>

<script>
import DxFunnel from 'devextreme-vue/funnel';

export default {
    components: {
        DxFunnel
    },
    methods: {
        onHoverChanged (e) {
            if (e.item.isHovered()) {
                // Commands to execute when the pointer enters the item
            } else {
                // Commands to execute when the pointer leaves the item
            }
        }
    }
}
</script>
React
App.js
import React from 'react';
import Funnel from 'devextreme-react/funnel';

class App extends React.Component {
    render() {
        return (
            <Funnel
                onHoverChanged={onHoverChanged}
            />
        );
    }
}

function onHoverChanged (e) {
    if (e.item.isHovered()) {
        // Commands to execute when the pointer enters the item
    } else {
        // Commands to execute when the pointer leaves the item
    }
}

export default App;

If you are going to change the event handler at runtime or if you need to attach several handlers to the hoverChanged event, subscribe to this event using the on(eventName, eventHandler) method. This approach is more typical of jQuery.

JavaScript
var hoverChangedHandler1 = function (e) {
    // First handler of the "hoverChanged" event
};

var hoverChangedHandler2 = function (e) {
    // Second handler of the "hoverChanged" event
};

$("#funnelContainer").dxFunnel("instance")
    .on("hoverChanged", hoverChangedHandler1)
    .on("hoverChanged", hoverChangedHandler2);
See Also