|
JS:
$("#container").ejChart({
//...
displayTextRendering:"textRender",
});
function textRender(sender){
var pointIndex = sender.data.pointIndex,
xValue = sender.data.series.points[pointIndex].x,
yValue = sender.data.series.points[pointIndex].y;
//Using the ej.format, we can format the number with respect to the requirement.
sender.data.text = xValue + " : " + ej.format(yValue, "c1", "en-US");
}
|
|
<link rel="stylesheet" rel='nofollow' href="http://cdn.syncfusion.com/16.2.0.41/js/web/flat-azure/ej.web.all.min.css" />
|
|
JS:
<div id="tooltipTemplate" style="display: none;color: whitesmoke; padding: 5px 5px 5px 5px">
<div id="values">
<div id="xValue">X Value : #point.x#</div>
<div id="yValue">Y Value: #point.y#</div>
</div>
</div>
$("#container").ejChart({
toolTipInitialize: function (args) {
var x = args.data.series.points[args.data.pointIndex].x,
y = args.data.series.points[args.data.pointIndex].y;
args.data.currentText = "<div id='values'><div id='xValue'>X Value : " + x +
"</div><div id='yValue'>Y Value: " + ej.format(y, "c1", "en-US") + "</div></div>";
},
});
|
|
JS:
function Export(anchor) {
//Get instance of chart
var chartObj = $("#container").ejChart("instance");
//Specify the size to chart with respect to your requirement
chartObj.model.legend.size.width = '130';
//Refresh the chart before exporting
chartObj.redraw();
chartCanvas = chartObj.export();
if (window.navigator.msSaveOrOpenBlob)
window.navigator.msSaveOrOpenBlob(chartCanvas.msToBlob(), "Chart.png");
else {
var chartData = chartCanvas.toDataURL();
anchor.download = "Chart.png";
anchor.rel='nofollow' href = chartData;
}
//After exporting specify the width to its default and refresh the chart, so that the chart will have scrollbar for the text which crossed the legend bounds
chartObj.model.legend.size.width = null;
chartObj.redraw();
}
|
|
Query |
Response | |
|
When doing the tooltip, it appears args.data.series.points doesn't exist. I believe args.model.series has a term visiblePoints or something. Is there something I'm missing here? |
Yes, while using the tooltip without template you can get form args.model.series and while using the template you can get it from args.data.series. Find the code snippet below.
The difference in between the arguments points and the visiblePoints are such that the points argument hold the data which includes empty points(i.e the y value may take null values), whereas the visiblePoints holds only the rendered points that are visible in DOM.
Sample for empty point: http://jsplayground.syncfusion.com/vng12pa5
| |
|
Also just like I did chartObj.model.legend.size.width = '130' is it possible to do chartObj.model.legend.visible = 'true'? I've tried but haven't had any results. |
If you don’t need to have legends on exporting as image, then before exporting you can hide the legend using the below code snippet.
If this is not your exact requirement, kindly provide us more information on the exact requirement for the code snippet chartObj.model.legend.visible = 'true', so that we can provide you the solution sooner.
|