Search results

User Interaction in Vue Linear Gauge component

14 Oct 2021 / 4 minutes to read

Tooltip

Linear gauge displays the details about a pointer value through tooltip, when the mouse hovers over the pointer. To enable the tooltip, set the enable property to true and inject the GaugeTooltip module in provide section.

Source
Preview
app.vue
Copied to clipboard
<template>
  <div class="content-wrapper">
    <div align='center'>
      <ejs-lineargauge   :tooltip='tooltip' >
        <e-axes>
          <e-axis >
            <e-pointers>
              <e-pointer value=80 ></e-pointer>
            </e-pointers>
          </e-axis>
        </e-axes>
      </ejs-lineargauge>
    </div>
  </div>
</template>
<script>
import Vue from 'vue';
import { LinearGaugePlugin, GaugeTooltip } from "@syncfusion/ej2-vue-lineargauge";

Vue.use(LinearGaugePlugin);
export default {
  data: function () {
    return{
      tooltip: {
        enable: true
      }
    }
  },
  provide: {
    lineargauge: [ GaugeTooltip]
  },
};
</script>
<style>
#content-wrapper {
    padding: 0px !important;
}
</style>

Tooltip Format

Tooltip in the Linear Gauge control can be formatted using the format property in tooltip object. It is used to render the tooltip in certain format or to add a user-defined unit in the tooltip. By default, the tooltip shows the pointer value only. In addition to that, more information can be added in the tooltip. For example, the format {value}km shows pointer value with kilometer unit in the tooltip.

Source
Preview
app.vue
Copied to clipboard
<template>
  <div class="content-wrapper">
    <div align='center'>
      <ejs-lineargauge :tooltip='tooltip'>
        <e-axes>
          <e-axis>
            <e-pointers>
              <e-pointer value=80 ></e-pointer>
            </e-pointers>
          </e-axis>
        </e-axes>
      </ejs-lineargauge>
    </div>
  </div>
</template>
<script>
import Vue from 'vue';
import { LinearGaugePlugin, GaugeTooltip } from "@syncfusion/ej2-vue-lineargauge";

Vue.use(LinearGaugePlugin);
export default {
  data: function () {
    return{
      tooltip: {
        enable: true,
        format: '{value}km'
      }
    }
  },
  provide: {
    lineargauge: [ GaugeTooltip]
  },
};
</script>
<style>
#content-wrapper {
    padding: 0px !important;
}
</style>

Tooltip Template

The HTML element can be rendered in the tooltip of the Linear Gauge using the template property in the tooltip. The ${value} can be used as placeholders in the HTML element to display the pointer values of the corresponding axis.

Source
Preview
app.vue
Copied to clipboard
<template>
  <div class="content-wrapper">
    <div align='center'>
      <ejs-lineargauge :tooltip='tooltip'>
        <e-axes>
          <e-axis >
            <e-pointers>
              <e-pointer value=80></e-pointer>
            </e-pointers>
          </e-axis>
        </e-axes>
      </ejs-lineargauge>
    </div>
  </div>
</template>
<script>
import Vue from 'vue';
import { LinearGaugePlugin, GaugeTooltip } from "@syncfusion/ej2-vue-lineargauge";
Vue.use(LinearGaugePlugin);
export default {
  data: function () {
    return{
      tooltip: {
        enable: true,
        template: '<div>Pointer: 80 </div>'
      }
    }
  },
  provide: {
    lineargauge: [GaugeTooltip]
  },
};
</script>
<style>
#content-wrapper {
    padding: 0px !important;
}
</style>

Customize the appearance of the tooltip

The tooltip can be customized using the following properties in tooltip.

  • fill - To fill the color for tooltip.
  • enableAnimation - To enable or disable the tooltip animation.
  • border - To set the border color and width of the tooltip.
  • textStyle - To customize the style of the text in tooltip.
  • showAtMousePosition - To show the tooltip at the mouse position.
Source
Preview
app.vue
Copied to clipboard
<template>
  <div class="content-wrapper">
<div align='center'>
  <ejs-lineargauge :tooltip='tooltip'>
    <e-axes>
      <e-axis >
        <e-pointers>
          <e-pointer value=80></e-pointer>
        </e-pointers>
      </e-axis>
    </e-axes>
  </ejs-lineargauge>
</div>
  </div>
</template>
<script>
import Vue from 'vue';
import { LinearGaugePlugin, GaugeTooltip } from "@syncfusion/ej2-vue-lineargauge";
Vue.use(LinearGaugePlugin);
export default {
  data: function () {
return{
  tooltip: {
    enable: true,
    fill: '#e5bcbc',
    border: {
      color: '#d80000',
      width: 2
    }
  }
}
  },
  provide: {
lineargauge: [ GaugeTooltip]
  },
};
</script>
<style>
#content-wrapper {
padding: 0px !important;
}
</style>

Positioning the tooltip

The tooltip is positioned at the End of the pointer. To change the position of the tooltip at the start, or center of the pointer, set the position property to Start or Center.

Source
Preview
app.vue
Copied to clipboard
<template>
  <div class="content-wrapper">
<div align='center'>
  <ejs-lineargauge :tooltip='tooltip'>
    <e-axes>
      <e-axis >
        <e-pointers>
          <e-pointer value=80 type="Bar" color="blue"></e-pointer>
        </e-pointers>
      </e-axis>
    </e-axes>
  </ejs-lineargauge>
</div>
  </div>
</template>
<script>
import Vue from 'vue';
import { LinearGaugePlugin, GaugeTooltip } from "@syncfusion/ej2-vue-lineargauge";
Vue.use(LinearGaugePlugin);
export default {
  data: function () {
return{
  tooltip: {
    enable: true,
    position: "Center"
  }
}
  },
  provide: {
lineargauge: [ GaugeTooltip]
  },
};
</script>
<style>
#content-wrapper {
padding: 0px !important;
}
</style>

Pointer Drag

To drag either marker or bar pointer to the desired axis value, set the enableDrag property as true in the e-pointer.

Source
Preview
app.vue
Copied to clipboard
<template>
  <div class="content-wrapper">
<div align='center'>
  <ejs-lineargauge >
    <e-axes>
      <e-axis >
        <e-pointers>
          <e-pointer value=80  enableDrag= 'true' ></e-pointer>
        </e-pointers>
      </e-axis>
    </e-axes>
  </ejs-lineargauge>
</div>
  </div>
</template>
<script>
import Vue from 'vue';
import { LinearGaugePlugin } from "@syncfusion/ej2-vue-lineargauge";
Vue.use(LinearGaugePlugin);
export default { };
</script>
<style>
#content-wrapper {
padding: 0px !important;
}
</style>