<script id="scriptInit" type="text/javascript">
$(document).ready(function () {
var xArray = [100, 200, 400, 800, 1000];
var yArray = [-20, 0, 30, -50, 100];
$("#wijlinechart").wijlinechart({
axis: {
y: {
origin: 0
}
},
showChartLabels: false,
hint: {
content: function () {
return this.data.lineSeries.label + '\n' +
this.x + '\n' + this.y + '';
},
contentStyle: {"font-size": 10},
offsetY: -10
},
legend: {visible: false},
seriesList: [
{
label: "My Stocks",
legendEntry: true,
data: {x: xArray, y: yArray},
markers: {visible: true, type: "circle"}
}
]
});
$("#wijlinechart").click(function (e) {
var offset = $(this).offset(),
left = e.pageX - offset.left,
top = e.pageY - offset.top,
lineChart = $(this).data("wijmoWijlinechart"),
bounds = lineChart.canvasBounds,
xMin = lineChart.axisInfo.x.min,
xMax = lineChart.axisInfo.x.max,
yMin = lineChart.axisInfo.y[0].min,
yMax = lineChart.axisInfo.y[0].max,
xVal, yVal;
if (left <= bounds.startX || left >= bounds.endX
|| top <= bounds.startY || top >= bounds.endY) {
return;
}
xVal = xMin + (left - bounds.startX) / (bounds.endX - bounds.startX)
* (xMax - xMin);
yVal = yMax - (top - bounds.startY) / (bounds.endY - bounds.startY)
* (yMax - yMin);
alert("The New Data Point is " + "x:" + Math.round(xVal, 10) + ", y:" + Math.round(yVal, 10));
xArray.push(Math.round(xVal, 10));
yArray.push(Math.round(yVal, 10));
$("#wijlinechart").wijlinechart({
seriesList: [
{
label: "My Stocks",
legendEntry: true,
data: {x: xArray, y: yArray},
markers: {visible: true, type: "circle"}
}]
});
$("#wijlinechart").wijlinechart("redraw", "true");
});
});
</script |