Search results

Target Bar in Vue Bullet Chart component

27 Oct 2021 / 2 minutes to read

The line marker that runs perpendicular to the orientation of the graph is known as the Comparative Measure and it is used as a target marker to compare against the feature measure value. This is also called as the Target Bar in the Bullet Chart. To display the target bar, the targetField should be mapped to the appropriate field from the datasource.

Source
Preview
app.vue
Copied to clipboard
<template>
  <div>
      <ejs-bulletchart id="bulletChart"
        :dataSource="data"
        valueField="value"
        targetField="target"
        :minimum="minimum"
        :maximum="maximum"
        :interval="interval"
        title="Sales Rate"
      >
      <e-bullet-range-collection>
          <e-bullet-range end="35" color="red"></e-bullet-range>
          <e-bullet-range end="50" color="blue"></e-bullet-range>
          <e-bullet-range end="100" color="green"></e-bullet-range>
        </e-bullet-range-collection>
      </ejs-bulletchart>
  </div>
</template>
<script>
import Vue from 'vue';
import { BulletChartPlugin } from '@syncfusion/ej2-vue-charts';
Vue.use(BulletChartPlugin);

export default {
  data () {
    return {
      data: [{ value: 55, target: 75 }],
      minimum: 0, maximum: 100, interval: 20
    }
  }
}
</script>

Types of Target Bar

The shape of the target bar can be customized using the targetTypes property and it supports Circle, Cross, and Rect shapes. The default type of the target bar is Rect.

Source
Preview
app.vue
Copied to clipboard
<template>
  <div>
      <ejs-bulletchart id="bulletChart"
        :dataSource="data"
        valueField="value"
        targetField="target"
        :minimum="minimum"
        :maximum="maximum"
        :interval="interval"
        title="Sales Rate"
        :targetTypes="targetTypes"
      >
      <e-bullet-range-collection>
          <e-bullet-range end="35" color="red"></e-bullet-range>
          <e-bullet-range end="50" color="blue"></e-bullet-range>
          <e-bullet-range end="100" color="green"></e-bullet-range>
        </e-bullet-range-collection>
      </ejs-bulletchart>
  </div>
</template>
<script>
import Vue from 'vue';
import { BulletChartPlugin } from '@syncfusion/ej2-vue-charts';
Vue.use(BulletChartPlugin);

export default {
  data () {
    return {
      data: [{ value: 55, target: 75 }],
      minimum: 0, maximum: 100, interval: 20, targetTypes: ["Circle"]
    }
  }
}
</script>

Target Bar Customization

The following properties can be used to customize the Target Bar.

Source
Preview
app.vue
Copied to clipboard
<template>
  <div>
  <ejs-bulletchart id="bulletChart"
    :dataSource="data"
    valueField="value"
    targetField="target"
    :minimum="minimum"
    :maximum="maximum"
    :interval="interval"
    title="Sales Rate"
    targetColor="red"
    targetWidth=15
  >
  <e-bullet-range-collection>
      <e-bullet-range end="35" color="red"></e-bullet-range>
      <e-bullet-range end="50" color="blue"></e-bullet-range>
      <e-bullet-range end="100" color="green"></e-bullet-range>
    </e-bullet-range-collection>
  </ejs-bulletchart>
  </div>
</template>
<script>
import Vue from 'vue';
import { BulletChartPlugin } from '@syncfusion/ej2-vue-charts';
Vue.use(BulletChartPlugin);

export default {
  data () {
return {
  data: [{ value: 55, target: 75 }],
  minimum: 0, maximum: 100, interval: 20
    }
  }
}
</script>