Hi Kalpa,
Thanks for using Syncfusion product.
We have analyzed this. This can be achieved by following the below steps
· Specify intervalType as “days”
· Set interval to 7, so the it is like week calculation. 7 days are split as interval and forms a weekly view
· Trigger axesLabelRendering event in chart
· Code the below to display labels as week1, week2 and so on
[JS] function axisLabels (sender){ if(sender.data.axis.orientation == "horizontal"){ // for x axis labels var value = new Date(sender.data.label.Value) // changing to date format value = value.getWeek(); // get week number sender.data.label.Text = "week"+ value; // modify the text } } |
· To get the weeks the below method should be mentioned
[JS] Date.prototype.getWeek = function() { var determinedate = new Date(); determinedate.setFullYear(this.getFullYear(), this.getMonth(), this.getDate()); var D = determinedate.getDay(); if(D == 0) D = 7; determinedate.setDate(determinedate.getDate() + (4 - D)); var YN = determinedate.getFullYear(); var ZBDoCY = Math.floor((determinedate.getTime() - new Date(YN, 0, 1, -6)) / 86400000); var WN = 1 + Math.floor(ZBDoCY / 7); return WN; } |
We have also made a sample to illustrate this. Find it from the below location
The below shows the output of the attached sample
And also kindly share the below details, so that we can provide you a sample closer to your exact scenario
· Should your week start from Sunday or any other day ?
· Should your labels start from week1, week2, so on.. which is not depending on week number?
· Share your desired position of the labels either on the ticks or between the ticks in chart
Please let us know if you have any concern.
Thanks,
Jayavigneshwaran
Hi Kalpa,
Thanks for your revert.
We have analyzed this and replicated the scenario shown, in our sample.
This can be done by following the below steps
· Specify intervalType as “days”
· Set interval to 7, so the it is like week calculation. 7 days are split as interval and forms a weekly view
· Trigger axesLabelRendering event in chart
[JS] $("#container").ejChart( { axesLabelRendering : "axisLabels" }); |
· Code the below to display labels as week1, week2 and so on
[JS] function axisLabels (sender){ if(sender.data.axis.orientation == "horizontal"){ // for x axis labels count++; // to find the no of labels sender.data.label.Text += "-week"+ count; // modify the text } } |
The below screen shot shows the output of the above code
We have also made a sample for your reference. Find it from the below location
datetime.zip
Please let us know if you have any concern.
Thanks,
Jayavigneshwaran
Hi Kalpa,
Currently there is no support to divide the axis based on the weeks interval. This can be achieved only if the interval is calculated as weeks. We have logged this as a feature request in our database. We will implement this feature in any of our upcoming releases.
Please let us know if you have any concern.
Thanks,
Jayavigneshwaran