Posted 8 January 2019, 1:22 am EST
How can i set the border color of a chart in spreadjs? The frame around the chart.
Forums Home / Spread / SpreadJS
Posted by: martin.mayr on 8 January 2019, 1:22 am EST
Posted 8 January 2019, 1:22 am EST
How can i set the border color of a chart in spreadjs? The frame around the chart.
Posted 9 January 2019, 1:15 am EST
Hi Martin,
I could not find a direct way to set the chart border, however, you can use the work-around as below to set the border for chart:
$(“#btn-setBorder”).click(function () {
var canvas = document.querySelectorAll('canvas'); for (var i = 0; i < canvas.length; i++) { if (canvas[i].id == "") { var context = canvas[i].getContext('2d'); context.fillStyle = "black"; context.font = "50px Arial"; context.globalCompositeOperation = "destination-over"; context.fillStyle = "#00FFFF"; context.fillRect(0, 0, canvas[i].width, canvas[i].height); context.globalCompositeOperation = "source-over"; context.lineWidth = 2; context.strokeStyle = "#FF0000"; context.strokeRect(0, 0, canvas[i].width, canvas[i].height); } } });
Also you would need to set the border everytime chart is re-painted .
Please refer to the attached sample.
Thanks,
Deepak SharmaSpreadJSChartBorder.zip
Posted 11 January 2019, 12:23 am EST
I would prefer a proper chart border property instead of having to paint the border myself…
Posted 11 January 2019, 1:01 am EST
and painting a border won’t work when exporting the chart to pdf…
Posted 13 January 2019, 10:12 pm EST
Hello,
Please note that charts are currently not exported to pdf with default export.
I have submitted the enhancement request to add a property to set chart’s border in SpreadJS.
The request id for this is 269101.
Thanks,
Deepak Sharma