JavaScript
onload = function() {
// create the chart
var theChart = new wijmo.chart.FlexChart('#theChart', {
itemsSource: getData(),
bindingX: 'date',
chartType: 'Candlestick',
legend: { position: 'None' },
series: [
{ binding: 'low,high,open,close', name: 'Alphabet Inc' }
]
});
// add annotation layer
var annotations = new wijmo.chart.annotation.AnnotationLayer(theChart, [
{ // attach an Ellipse to data point 15
type: 'Ellipse',
content: 'Ellipse',
tooltip: 'This is an <b>Ellipse</b><br/>annotation',
attachment: 'DataIndex',
seriesIndex: 0,
pointIndex: 15,
width: 100, height: 40,
position: 'Top', // Center/Top/Bottom/Left/Right
style: { fill: 'green', stroke: 'darkgreen', strokeWidth: 2, opacity: .25 }
},
{ // show a trendline between Jan 31 and Feb 27
type: 'Line',
tooltip: 'This is a <b>Line</b><br/>annotation',
position: 'Center',
content: 'content',
attachment: 'DataCoordinate',
start: { x: new Date(2017, 0, 31), y: 810 },
end: { x: new Date(2017, 1, 28), y: 840 },
style: { stroke: 'darkgreen', strokeWidth: 4, opacity: .5 }
},
{ // show a trendline between Jan 31 and Feb 27
type: 'Polygon',
tooltip: 'This is a <b>Line</b><br/>annotation',
position: 'Center',
content: 'not showing content',
attachment: 'DataCoordinate',
points: [{ x: new Date(2017, 0, 5), y: 850 }, { x: new Date(2017, 1, 2), y: 850 }, { x: new Date(2017, 1, 2), y: 810 }, { x: new Date(2017, 0, 5), y: 810 }],
style: { stroke: 'darkgreen', strokeWidth: 4, opacity: .5 }
}
]);
// some stock data from Google Finance
function getData() {
return [
{ date: new Date(2017,2,15), open: 867.94, high: 869.88, low: 861.3, close: 868.39, vol: 1332885},
{ date: new Date(2017,2,14), open: 863.75, high: 867.58, low: 860.13, close: 865.91, vol: 1061692},
{ date: new Date(2017,2,13), open: 860.83, high: 867.13, low:...