Essential Chart supports formatting labels in an axis using labelFormat property of axis. This property takes a format string as value based on the value type of axis. You can display the date values in the date time axis in date, month, year, time, date/month/year, etc., formats using labelFormat property. By default, Chart automatically formats the axis labels smartly, based on the calculated minimum and maximum values of data points. You can also specify the desired format to the labels using labelFormat property. The following code example illustrates this. JS $("#container").ejChart({ primaryXAxis: { labelFormat: 'MMM dd, yyyy' }, series: [{ points: [{ x: new Date("1 /1/2014"), y: 35 }, { x: new Date("2/1/2014"), y: 25 }, { x: new Date("3/1/2014"), y: 34 }, { x: new Date("4/1/2014"), y: 65 }, { x: new Date("5/1/2014"), y: 73 }, { x: new Date("6/1/2014"), y: 37 } ], name: 'series' }] }); The following screenshot displays the Chart with primary X axis in “MMM dd, yyyy” format. Figure 1: Chart with primary X axis in “MMM dd, yyyy” format JS Playground sample link: Datetime Labels Formatting Date Time formats The following table illustrates the various date time formats for axis labels.
|
This page will automatically be redirected to the sign-in page in 10 seconds.