|
HTML:
<ejs-chart id="chart-container" (loaded)='loaded($event)' >
<e-annotations>
<e-annotation content='<svg id="myannot" height="5" width="500">
<line id="myline" x1="0" y1="0" x2="500" y2="0" stroke-dasharray="5" style="stroke:rgb(255,0,0);stroke-width:5" />
</svg>' region='Series' coordinateUnits='Point' x=1 y=15>
</e-annotation>
<e-annotation content='<svg id="myannot1" height="5" width="500">
<line id="myline1" x1="0" y1="0" x2="500" y2="0" stroke-dasharray="5" style="stroke:blue;stroke-width:5" />
</svg>' region='Series' coordinateUnits='Point' x=1 y=5>
</e-annotation>
<e-annotation content='3α' region='Series' coordinateUnits='Point' x=10 y=6 horizontalAlignment='Near'>
</e-annotation>
</e-annotations>
</ejs-chart>
TS:
public loaded(args: ILoadedEventArgs): void {
var chartAreaRect=document.getElementById('chart-container_ChartAreaBorder');
//Adding first annoation
var myAnnotation=document.getElementById('chart-container_Annotation_0');
var mySVGLine=document.getElementById('myline');
var mySVG=document.getElementById('myannot');
myAnnotation.style.left=chartAreaRect.x.baseVal.value.toString()+"px";
mySVG.width.baseVal.value=chartAreaRect.width.baseVal.value;
mySVGLine.x2.baseVal.value=chartAreaRect.width.baseVal.value;
// Adding second annotaion
var myAnnotation1=document.getElementById('chart-container_Annotation_1');
var mySVGLine1=document.getElementById('myline1');
var mySVG1=document.getElementById('myannot1');
myAnnotation1.style.left=chartAreaRect.x.baseVal.value.toString()+"px";
mySVG1.width.baseVal.value=chartAreaRect.width.baseVal.value;
mySVGLine1.x2.baseVal.value=chartAreaRect.width.baseVal.value;
} |