0

I'm trying to change the label format from date to string.

I tried changing the formats but it didn't work. Here is my codepen: https://codepen.io/sampath-PerOxide/pen/bzVOoG

var dateformat = "%Y-%m"
drawTimeSeriesGraph(data1, dateformat);

I want to pass the string in the place of the date.

ksav
  • 20,015
  • 6
  • 46
  • 66
Sampath
  • 153
  • 2
  • 13

1 Answers1

1

You can format your axis ticks however you like with tickFormat. Just pass it your own function that returns the string you want based on the data (the function can access the current datum and index).

xAxis.tickFormat((d, i) => {
    const date = formatDate(d)
    return `${date} - Month ${i+1}`
});

Codepen

ksav
  • 20,015
  • 6
  • 46
  • 66