Vue Chart - Show and Hide a Tooltip
Each series point allows you to show or hide its tooltip programmatically. For this, call the showTooltip() or hideTooltip() method of the Point object. You can access this object with the API methods or in the handlers of the point events, such as pointClick, pointHoverChanged, etc. The latter is demonstrated in the following code.
App.js
- import React from 'react';
- import Chart from 'devextreme-react/chart';
- class App extends React.Component {
- render() {
- return (
- <Chart ...
- onPointClick={onPointClick}
- onPointHoverChanged={onPointHoverChanged}>
- </Chart>
- );
- }
- }
- function onPointHoverChanged (e) {
- const point = e.target;
- if (!point.isHovered()) {
- point.hideTooltip();
- }
- }
- function onPointClick (e) {
- const point = e.target;
- point.showTooltip();
- }
- export default App;
You can also hide the tooltip regardless of the point to which it belongs. To do this, call the hideTooltip() method of the Chart instance.
App.js
- import React from 'react';
- import Chart from 'devextreme-react/chart';
- class App extends React.Component {
- constructor(props) {
- super(props);
- this.chartRef = React.createRef();
- this.hideTooltip = this.hideTooltip.bind(this);
- }
- render() {
- return (
- <Chart ref={this.chartRef}></Chart>
- );
- }
- get chart() {
- return this.chartRef.current.instance();
- }
- hideTooltip () {
- this.chart.hideTooltip();
- }
- }
- export default App;
See Also
Feel free to share topic-related thoughts here.
If you have technical questions, please create a support ticket in the DevExpress Support Center.
Thank you for the feedback!
If you have technical questions, please create a support ticket in the DevExpress Support Center.