<template>
<div class="main" ref="gauge" align="left">
<ejs-lineargauge :height="size.height" align="left"
:width="size.width" background="transparent" id='container1'
allow-margin="false" orientation='Horizontal' :container='container1'>
<e-axes align="left">
<e-axis :line='line1' :labelStyle='labelStyle1' :ranges='gRanges' align="left"
:majorTicks="majorTick1" :minorTicks="minorTick1" >
<e-pointers align="left">
<e-pointer align="left" :value='graphValue' :height='height1' :color='graphColor' :placement='placement1' :offset='offset1' type="Bar"></e-pointer>
</e-pointers>
</e-axis>
</e-axes>
</ejs-lineargauge>
</div>
</template>
<style scoped>
#control-container {
padding: 0px !important;
}
</style>
<script>
import { LinearGaugePlugin } from "@syncfusion/ej2-vue-lineargauge";
import { defineComponent } from '@vue/composition-api'
export default defineComponent({
name:"LinearGaugeCustom",
component:{
LinearGaugePlugin,
},
props:{
orientationType: String,
gaugeDesign: Object,
valueDesign: Object,
graphValue: Number
},
computed:{
orientation:function(){
if(this.gaugeDesign === undefined)
return 'Horizontal';
console.log(this.orientationType);
if(this.orientationType.indexOf('GaugeVertical')!= -1)
return 'Vertical';
else
return 'Horizontal';
},
minimum : function(){
return 0;
},
maximum : function(){
if(this.gaugeDesign===undefined)
return 100;
else
return this.gaugeDesign.ValueEnd;
},
gRanges : function(){
if(this.gaugeDesign===undefined)
return [];
let uniformWidth = 100;
let range1 = {
start: 0,
end: this.gaugeDesign.Limit2,
startWidth: uniformWidth,
endWidth: uniformWidth,
color: 'rgba(54, 197, 0, 0.7)'
}
let range2 = {
start: this.gaugeDesign.Limit2,
end: this.gaugeDesign.Limit3,
startWidth: uniformWidth,
endWidth: uniformWidth,
color: 'rgba(243, 157, 7, 0.7)'
}
let range3 = {
start: this.gaugeDesign.Limit3,
end: this.gaugeDesign.ValueEnd,
startWidth: uniformWidth,
endWidth: uniformWidth,
color: 'rgba(244, 0, 0, 0.7)'
}
return [range1,range2, range3];
},
isBlinkOnLimit2:function() {
if(this.gaugeDesign === undefined)
return false;
else
return this.gaugeDesign.isBlinkOnLimit3; },
isBlinkOnLimit3:function() {
if(this.gaugeDesign === undefined)
return false;
else
return this.gaugeDesign.isBlinkOnLimit3; },
isShowValueWithGraph:function() {
if(this.gaugeDesign === undefined)
return false;
else
return this.gaugeDesign.IsShowValueWithGraph; },
graphColor: function(){
if(this.gaugeDesign === undefined)
return 'gray';
if(this.graphValue < this.gaugeDesign.Limit2)
return this.gRanges[0].color; //green
else if(this.graphValue < this.gaugeDesign.Limit3 && this.graphValue > this.gaugeDesign.Limit2)
return this.gRanges[1].color; //orange
else if(this.graphValue > this.gaugeDesign.Limit3)
return this.gRanges[2].color; //red
else
return 'gray';
}
},
data:function(){
return{
size: {
height: '100%', width: '100%'
},
orientation1: 'Horizontal',
container1: {
width: 30, //done
border: {
width: 0
},
offset: 30 //done
},
line1: {
offset:35 //done
},
labelStyle1: {
font : {size: '0px'} //font-size of label, 0 means do not show
},
placement1: 'Near',
offset1: 0, //offset of pointer
height1: 200, //height of pointer
majorTick1: { height: 100, width: 1}, //ticks
minorTick1: { height: 100}, width: 1, //ticks
annotations1: []
}
},
mounted(){
console.log(this.valueDesign);
setTimeout(this.ReRenderThis(), 500);
},
watch:{
graphValue : function(){
const X = this.gaugeDesign.X - (0.15 * this.$refs.gauge.offsetWidth);
const Y = this.gaugeDesign.Y;
console.log(`Test : ${X},${Y}`);
}
},
methods: {
ReRenderThis:function(){
if(this.gaugeDesign==undefined)
{
const X = this.gaugeDesign.X - (0.15 * this.size.width);
const Y = this.gaugeDesign.Y;
console.log(`Test : ${X},${Y}`);
}
}
}
})
</script>
<style scoped>
</style>