3

I have a script using Highchart graphic:

http://jsfiddle.net/9C4jA/1/

And I'm tyring to customize with datetime.

Actually is saving using with filename

  Report.jpg
  Report.pdf
  Report.png

But i want to add the date

 Reporte_2014-14-05.jpg
 Reporte_2014-14-05.pdf
 Reporte_2014-14-05.png

Please somebody can help me?

Matt Burland
  • 44,552
  • 18
  • 99
  • 171
Carlos Morales
  • 1,137
  • 3
  • 15
  • 38

1 Answers1

4

It is pretty simple. If you want the date you can create it like (taken from here):

var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!

var yyyy = today.getFullYear();
if(dd<10){dd='0'+dd} if(mm<10){mm='0'+mm} today = mm+'-'+dd+'-'+yyyy;

Then you need to create some sort of template file name:

var fileName = 'theFile_' + today;

Then when you export it you have a custom name:

exporting: {
    filename: fileName
}

See demo here.

Community
  • 1
  • 1
wergeld
  • 14,332
  • 8
  • 51
  • 81
  • beat me to the answer, but here's a fiddle where I was testing it out: http://jsfiddle.net/z72yv/, I used the excellent `moment.js` to generate the date string. – Mark Jan 21 '14 at 21:39
  • Seems that i need to add something after "Report" like date – Carlos Morales Jan 21 '14 at 21:58
  • @CarlitosMorales, this is what I put into my chart declaration. Are you wanting to modify the export source js file? – wergeld Jan 21 '14 at 22:45
  • http://jsfiddle.net/gh/get/jquery/1.9.1/highslide-software/highcharts.com/tree/master/samples/highcharts/demo/pie-legend/ ........I'm trying to personalize this – Carlos Morales Jan 21 '14 at 22:55
  • @CarlitosMorales, yes, this code will do that. See example in edited answer. – wergeld Jan 21 '14 at 23:12