This question is locked. New answers and comments are not allowed.
hi,
I want to draw a Gantt chart with date on X-axis, Time on Y-axis.
I need to get all the values from XML.
Can u share some sample code to draw a Gantt chart like for a particular day from one particular time to another particular time.?
how i need to write a XML so that the chart can bind the XML data to the chart?
ex: on 02-06-2008 i should plot the gantt chart from 5:00 P.M to 7.00 P.M
help is highly appreciated.
regards,
chandra
I want to draw a Gantt chart with date on X-axis, Time on Y-axis.
I need to get all the values from XML.
Can u share some sample code to draw a Gantt chart like for a particular day from one particular time to another particular time.?
how i need to write a XML so that the chart can bind the XML data to the chart?
ex: on 02-06-2008 i should plot the gantt chart from 5:00 P.M to 7.00 P.M
help is highly appreciated.
regards,
chandra
12 Answers, 1 is accepted
0
Hi Chandra,
There is no need to change the data source (XML in your case). You just need to change the Series Orientation of the RadChart:
For more information about XML data sources, please, refer to the example in our QSF. There you can also find an example demonstrating Gantt chart ((RadChart >> Chart Types >> Gantt).
Sincerely yours,
Evtim
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
There is no need to change the data source (XML in your case). You just need to change the Series Orientation of the RadChart:
this.radChart1.SeriesOrientation = ChartSeriesOrientation.Vertical; |
For more information about XML data sources, please, refer to the example in our QSF. There you can also find an example demonstrating Gantt chart ((RadChart >> Chart Types >> Gantt).
Sincerely yours,
Evtim
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0

chandra
Top achievements
Rank 1
answered on 03 Jun 2008, 01:26 PM
Hi Evtim,
as per my understanding and according to the example in QFS.... on X-axis we need to draw the chart (From point to To point).but for a particular date how can we have the fromDate and toDate???
As mentioned in my previous query:
ex: For date 02-06-2008, i need to draw the chart from 5:00 P.M to 7.00 P.M.
Ranges to plot graph are:
------------------------------
Date range is : 02-06-2008 to 12-06-2008
time range is : 0:00 to 24:00
ex: values in XML are
<Day Date="02/06/2008" From="02/06/2008 08:45 PM" To="02/06/2008 04:55 AM"></Day>
<Day Date="21/05/2008" From="21/05/2008 10:45 PM" To="22/05/2008 06:55 AM"></Day>
as per my understanding and according to the example in QFS.... on X-axis we need to draw the chart (From point to To point).but for a particular date how can we have the fromDate and toDate???
As mentioned in my previous query:
ex: For date 02-06-2008, i need to draw the chart from 5:00 P.M to 7.00 P.M.
Ranges to plot graph are:
------------------------------
Date range is : 02-06-2008 to 12-06-2008
time range is : 0:00 to 24:00
ex: values in XML are
<Day Date="02/06/2008" From="02/06/2008 08:45 PM" To="02/06/2008 04:55 AM"></Day>
<Day Date="21/05/2008" From="21/05/2008 10:45 PM" To="22/05/2008 06:55 AM"></Day>
0
Hi chandra,
Unfortunately, plotting dates is not straight-forward. You need to convert the dates to Ole Automation format.
Please, refer to the following example (especially lines 20, 26 and 61 to 64):
As you can see, all dates are converted to double using DateTime.ToOADate().
I hope this information will help you solve the problem. If you have further assistance, drop me a line.
All the best,
Evtim
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Unfortunately, plotting dates is not straight-forward. You need to convert the dates to Ole Automation format.
Please, refer to the following example (especially lines 20, 26 and 61 to 64):
public Form1() | |
{ | |
InitializeComponent(); | |
} | |
protected override void OnLoad(EventArgs e) | |
{ | |
base.OnLoad(e); | |
DateTime today = DateTime.Today; | |
// Setup chart orientation | |
this.radChart1.SeriesOrientation = ChartSeriesOrientation.Horizontal; | |
// Setup XAxis | |
this.radChart1.PlotArea.XAxis.IsZeroBased = false; | |
this.radChart1.PlotArea.XAxis.Appearance.ValueFormat = Telerik.Charting.Styles.ChartValueFormat.ShortDate; | |
this.radChart1.PlotArea.XAxis.AutoScale = false; | |
this.radChart1.PlotArea.XAxis.AddRange(today.ToOADate(), today.AddDays(10).ToOADate(), 1); | |
this.radChart1.PlotArea.XAxis.LayoutMode = Telerik.Charting.Styles.ChartAxisLayoutMode.Inside; | |
// Setup YAxis | |
this.radChart1.PlotArea.YAxis.IsZeroBased = false; | |
this.radChart1.PlotArea.YAxis.Appearance.ValueFormat = Telerik.Charting.Styles.ChartValueFormat.ShortTime; | |
this.radChart1.PlotArea.YAxis.AutoScale = false; | |
this.radChart1.PlotArea.YAxis.AddRange(today.AddHours(7).ToOADate(), today.AddHours(18).ToOADate(), 1d/24d); | |
// Setup Series | |
this.radChart1.Series[0].Type = ChartSeriesType.Gantt; | |
this.radChart1.Series[0].DataXColumn = "X"; | |
this.radChart1.Series[0].DataXColumn2 = "X2"; | |
this.radChart1.Series[0].DataYColumn = "Y"; | |
this.radChart1.Series[0].DataYColumn2 = "Y2"; | |
// Data Bind | |
this.radChart1.Series[0].Appearance.LabelAppearance.Visible = false; | |
this.radChart1.DataSource = GenerateSource("Table"); | |
this.radChart1.DataMember = "Table"; | |
this.radChart1.DataBind(); | |
} | |
private DataSet GenerateSource(string tableName) | |
{ | |
double[,] input = new double[3, 2] { | |
{ 8, 12 }, { 9, 14}, { 13, 18.5} | |
}; | |
DataTable table = new DataTable(tableName); | |
table.Columns.Add("X", typeof(double)); | |
table.Columns.Add("X2", typeof(double)); | |
table.Columns.Add("Y", typeof(double)); | |
table.Columns.Add("Y2", typeof(double)); | |
DateTime start = DateTime.Today; | |
for(int i = 0; i < 3; i++ ) | |
{ | |
DataRow row = table.NewRow(); | |
row["X"] = start.AddDays(i).ToOADate(); | |
row["X2"] = start.AddDays(i + 1).ToOADate(); | |
row["Y"] = start.AddHours(input[i, 0]).ToOADate(); | |
row["Y2"] = start.AddHours(input[i, 1]).ToOADate(); | |
table.Rows.Add(row); | |
} | |
DataSet dataSet = new DataSet(); | |
dataSet.Tables.Add(table); | |
return dataSet; | |
} |
I hope this information will help you solve the problem. If you have further assistance, drop me a line.
All the best,
Evtim
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0

chandra
Top achievements
Rank 1
answered on 05 Jun 2008, 02:23 PM
hi Evtim,
Very very thanks for your Reply.
Thank you. It has satisfied my requirement.
But one thing.
on Y-axis we are taking the short time.
It is displaying the short time on Y- axis as
12:00 AM
01:00 AM
.........
.........
10:00 PM like this.
But I want to Display them as 12, 01,02,03,.......13,14,15,16,17.......
My actual Requirement is
DD/MM/YYYY DD/MM/YYYY
06/05/2008 07/05/2008
| |
V V
10, 12, 14, 16, 18, 20, 22, 24, 02, 04, 06, 08, 10
Is it possible? If so Plz share the sample code.
Thanks and Regards,
Chandra.
Very very thanks for your Reply.
Thank you. It has satisfied my requirement.
But one thing.
on Y-axis we are taking the short time.
It is displaying the short time on Y- axis as
12:00 AM
01:00 AM
.........
.........
10:00 PM like this.
But I want to Display them as 12, 01,02,03,.......13,14,15,16,17.......
My actual Requirement is
DD/MM/YYYY DD/MM/YYYY
06/05/2008 07/05/2008
| |
V V
10, 12, 14, 16, 18, 20, 22, 24, 02, 04, 06, 08, 10
Is it possible? If so Plz share the sample code.
Thanks and Regards,
Chandra.
0
Hi chandra,
You just need to specify the string format that is to be used on the corresponding axis:
For more information on string formatting, please, refer to the following blog:
http://blog.stevex.net/index.php/string-formatting-in-csharp/
Regards,
Evtim
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
You just need to specify the string format that is to be used on the corresponding axis:
this.radChart1.PlotArea.YAxis.Appearance.CustomFormat = "HH"; |
For more information on string formatting, please, refer to the following blog:
http://blog.stevex.net/index.php/string-formatting-in-csharp/
Regards,
Evtim
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0

chandra
Top achievements
Rank 1
answered on 09 Jun 2008, 11:58 AM
hi,
Very very thanks for your reply.
We are taking the Time on Y-axis. I want the change color of the bar, if the difference between the Y2 and Y is less than 4:00 hours.
Ex:
We are taking the input[]. In this one we have difined the values for Y and Y2.
I want the chartItem color in red, if (Y2 - Y < 4.00).
and
I want to show the label.
if I set this.radChart1.Series[0].Appearance.LabelAppearance.Visible=true,
It is showing the label in double format(39589.0555556).
But I want the label as difference of Y2,Y i.e 4.0, 3.6, 5.8 ...
I want to display these labels inside the Bar
EX:-
____ ____
| | | |
|4.6 | | 3.5 |
| | ____
____
If it is zero, i don't want to show label.
Very very thanks for your reply.
We are taking the Time on Y-axis. I want the change color of the bar, if the difference between the Y2 and Y is less than 4:00 hours.
Ex:
We are taking the input[]. In this one we have difined the values for Y and Y2.
I want the chartItem color in red, if (Y2 - Y < 4.00).
and
I want to show the label.
if I set this.radChart1.Series[0].Appearance.LabelAppearance.Visible=true,
It is showing the label in double format(39589.0555556).
But I want the label as difference of Y2,Y i.e 4.0, 3.6, 5.8 ...
I want to display these labels inside the Bar
EX:-
____ ____
| | | |
|4.6 | | 3.5 |
| | ____
____
If it is zero, i don't want to show label.
0

chandra
Top achievements
Rank 1
answered on 12 Jun 2008, 04:49 AM
hi,
I found the solution for the above Requirements.
I did like this.
If there is any better way to solve this one, plz share the code
Thanks and Regards,
Chandra.
I found the solution for the above Requirements.
I did like this.
//set the visibility of the label to true | |
radChart1.Series[0].Appearance.LabelAppearance.Visible = true; | |
//set the label location to inside the data item bar | |
radChart1.Series[0].Appearance.LabelAppearance.LabelLocation = Telerik.Charting.Styles.StyleSeriesItemLabel.ItemLabelLocation.Inside; | |
//set the position of the label inside the data item bar to center | |
radChart1.Series[0].Appearance.LabelAppearance.Position.AlignedPosition = Telerik.Charting.Styles.AlignedPositions.Center; | |
//create the chart series items collection | |
ChartSeriesItemsCollection items = this.radChart1.Series[0].Items; | |
for (int i = 0; i < items.Count; i++) | |
{ | |
// if the item value is zero, set the label visibility to false; | |
if(radChart1.Series[0].Items[i].Name=="0") | |
items[i].Label.Visible = false; | |
// set the fill type as solid(optional). | |
items[i].Appearance.FillStyle.FillType =Telerik.Charting.Styles.FillType.Solid; | |
// if the difference between the Yvalue2 and Yvalue is less than 4 hours | |
// set the maincolor of the item bar to red. | |
if (radChart1.Series[0].Items[i].YValue2 - radChart1.Series[0].Items[i].YValue <= 0.16742770169863013698630136986301) | |
{ | |
items[i].Appearance.FillStyle.MainColor = Color.Red; | |
} | |
else | |
{ | |
items[i].Appearance.FillStyle.MainColor = Color.FromArgb(102,255,0); | |
} | |
} | |
If there is any better way to solve this one, plz share the code
Thanks and Regards,
Chandra.
0
Hello chandra,
I'm glad you found a solution to the problem and shared it with the community.
Let us know if you need further assistance.
Regards,
Evtim
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
I'm glad you found a solution to the problem and shared it with the community.
Let us know if you need further assistance.
Regards,
Evtim
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0

kiran
Top achievements
Rank 1
answered on 10 Jul 2008, 07:12 AM
Hi Evtim,
I have the same requirement like drawing the gantt chart with date on x-axis and time on y-axis. In your example to chandra you have given like showing the continuos dates data. but i have a requirement of showing the discontinuos dates data. i am unable to do the same with code you have provided in this post.
i am using the datalabelscolumn property to show the discontinuos dates on x-axis but on y-axis i am unable to plot the values (for discontinuous dates 1,2,4,8 june and 1 july ). I have to plot four serieses.The following sample xml data i have to plot on the gantt chart.
Start0="525" Stop0="625" means on 01/06/2008 from 525 minutes to 625 minutes
start0,stop0 - series0
start1,stop1 - series1
start2,stop2 - series2
start3,stop3 - series3
i should have the chart like(I donot want to show the dates like 03,05,06,09...30 on the chart). We should show only the available dates data only.
|
|
|
-----------------------------------------------
01/06 02/06 04/06 08/06 01/07
Could you please provide a sample application / sample code which shows the discontinuous dates data in Gantt Chart. I need to resolve this problem as soon as possible. Please help me out.
Thanks in advance.
Regards,
Kiran
I have the same requirement like drawing the gantt chart with date on x-axis and time on y-axis. In your example to chandra you have given like showing the continuos dates data. but i have a requirement of showing the discontinuos dates data. i am unable to do the same with code you have provided in this post.
i am using the datalabelscolumn property to show the discontinuos dates on x-axis but on y-axis i am unable to plot the values (for discontinuous dates 1,2,4,8 june and 1 july ). I have to plot four serieses.The following sample xml data i have to plot on the gantt chart.
<Day Date="01/06/2008" Start0="525" Stop0="625" Start1="675" Stop1="800" Start2="875" Stop2="900" Start3="975" Stop3="1100" ></Day> |
<Day Date="02/06/2008" Start0="645" Stop0="800" Start1="840" Stop1="920" Start2="975" Stop2="1000" Start3="1075" Stop3="1200"></Day> |
<Day Date="04/06/2008" Start0="200" Stop0="400" Start1="500" Stop1="700" Start2="775" Stop2="800" Start3="875" Stop3="950"></Day> |
<Day Date="08/06/2008" Start0="320" Stop0="700" Start1="800" Stop1="900" Start2="1000" Stop2="1050" Start3="1100" Stop3="1200"></Day> |
<Day Date="01/07/2008" Start0="60" Stop0="71" Start1="525" Stop1="700" Start2="775" Stop2="800" Start3="875" Stop3="900"></Day> |
start0,stop0 - series0
start1,stop1 - series1
start2,stop2 - series2
start3,stop3 - series3
i should have the chart like(I donot want to show the dates like 03,05,06,09...30 on the chart). We should show only the available dates data only.
|
|
|
-----------------------------------------------
01/06 02/06 04/06 08/06 01/07
Could you please provide a sample application / sample code which shows the discontinuous dates data in Gantt Chart. I need to resolve this problem as soon as possible. Please help me out.
Thanks in advance.
Regards,
Kiran
0
Hello kiran,
You can manually add items to both XAxis and YAxis and set the desired values as you like. Here is an example demonstrating how to add custom items on the YAxis:
Should you have further questions, just drop us a line.
Regards,
Evtim
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
You can manually add items to both XAxis and YAxis and set the desired values as you like. Here is an example demonstrating how to add custom items on the YAxis:
double[] values = { | |
DateTime.Today.ToOADate(), | |
DateTime.Today.AddDays(1).ToOADate(), | |
DateTime.Today.AddDays(2).ToOADate(), | |
DateTime.Today.AddDays(3).ToOADate(), | |
DateTime.Today.AddDays(7).ToOADate(), | |
DateTime.Today.AddDays(11).ToOADate(), | |
DateTime.Today.AddDays(13).ToOADate(), | |
DateTime.Today.AddDays(17).ToOADate(), | |
DateTime.Today.AddDays(18).ToOADate() | |
}; | |
this.radChart1.PlotArea.YAxis.IsZeroBased = false; | |
this.radChart1.PlotArea.YAxis.Appearance.ValueFormat = Telerik.Charting.Styles.ChartValueFormat.ShortDate; | |
this.radChart1.PlotArea.YAxis.AutoScale = false; | |
for (int i = 0; i < values.Length; i++) | |
{ | |
ChartAxisItem item = new ChartAxisItem(); | |
item.Value = Convert.ToDecimal(values[i]); | |
this.radChart1.PlotArea.YAxis.AddItem(item); | |
} |
Should you have further questions, just drop us a line.
Regards,
Evtim
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0

kiran
Top achievements
Rank 1
answered on 10 Jul 2008, 10:53 AM
Hi Evtim,
This is not what i am expecting. i am binding the XML data to the chart. For gantt chart i hope we need four data items. X,X2,Y,Y2.
The following is the full code i am using. please go through it and do let me know the error in my code.
The C# code is:
Please look into the code and share us the comments.
I do not want to hard code the items into the values[] array. Please share a sample application to plot the discontinuos dates. I m in a big trouble now.
Thanks in advance.
Regards,
kiran
This is not what i am expecting. i am binding the XML data to the chart. For gantt chart i hope we need four data items. X,X2,Y,Y2.
The following is the full code i am using. please go through it and do let me know the error in my code.
Day Date="02/06/2008" From0="525" To0="625" From1="675" To1="800" From2="875" To2="900" From3="975" To3="1100" ></Day> |
<Day Date="03/06/2008" From0="645" To0="800" From1="840" To1="920" From2="975" To2="1000" From3="1075" To3="1200"></Day> |
<Day Date="04/06/2008" From0="200" To0="400" From1="500" To1="700" From2="775" To2="800" From3="875" To3="950"></Day> |
<Day Date="06/06/2008" From0="320" To0="700" From1="800" To1="900" From2="1000" To2="1050" From3="1100" To3="1200"></Day> |
<Day Date="07/06/2008" From0="60" To0="71" From1="525" To1="700" From2="775" To2="800" From3="875" To3="900"></Day> |
<Day Date="08/06/2008" From0="120" To0="560" From1="700" To1="925" From2="975" To2="1000" From3="1075" To3="1200"></Day> |
<Day Date="09/06/2008" From0="150" To0="300" From1="525" To1="700" From2="775" To2="800" From3="875" To3="1000"></Day> |
<Day Date="10/06/2008" From0="525" To0="625" From1="675" To1="900" From2="975" To2="1000" From3="1075" To3="1200"></Day> |
<Day Date="11/06/2008" From0="645" To0="800" From1="840" To1="920" From2="975" To2="1100" From3="1175" To3="1200"></Day> |
<Day Date="12/06/2008" From0="800" To0="900" From1="925" To1="940" From2="975" To2="1000" From3="1100" To3="1200"></Day> |
<Day Date="13/06/2008" From0="428" To0="900" From1="995" To1="1040" From2="1075" To2="1150" From3="1175" To3="1200"></Day> |
The C# code is:
private void LoadDataToUsageDataChart() |
{ |
//Create the XMLDocument Object |
usageXmlDocument = new XmlDocument(); |
//Load the XMLDocument |
usageXmlDocument.Load("../../XML/UsageData.xml"); |
//Create the XMLNodeList |
usageXmlNodeList = usageXmlDocument.SelectNodes("//Years"); |
//Count the number of Days that the Graph can show Data |
countTheDaysUsed(); |
dsUsageData.Tables.Clear(); |
dtGameData.Columns.Clear(); |
ChartSeries CS2 = new ChartSeries(); |
ChartSeries CS3 = new ChartSeries(); |
gphGameStats.Series.AddRange(new Telerik.Charting.ChartSeries[] { |
CS2, CS3}); |
//Define the Data Table Columns along with their types |
dtGameData.Columns.Add("SeriesDate", typeof(double)); |
dtGameData.Columns.Add("Series0X", typeof(double)); |
dtGameData.Columns.Add("Series0X2", typeof(double)); |
dtGameData.Columns.Add("Series0Y", typeof(double)); |
dtGameData.Columns.Add("Series0Y2", typeof(double)); |
dtGameData.Columns.Add("Series0Label", typeof(double)); |
dtGameData.Columns.Add("Series1Y", typeof(double)); |
dtGameData.Columns.Add("Series1Y2", typeof(double)); |
dtGameData.Columns.Add("Series1Label", typeof(double)); |
dtGameData.Columns.Add("Series2Y", typeof(double)); |
dtGameData.Columns.Add("Series2Y2", typeof(double)); |
dtGameData.Columns.Add("Series2Label", typeof(double)); |
dtGameData.Columns.Add("Series3Y", typeof(double)); |
dtGameData.Columns.Add("Series3Y2", typeof(double)); |
dtGameData.Columns.Add("Series3Label", typeof(double)); |
//Read the XML file data into Data Table |
usageXmlNodeList = usageXmlDocument.SelectNodes("//Years"); |
foreach (XmlNode node in usageXmlNodeList) |
{ |
if (node.HasChildNodes) |
{ |
readUsageChildNodeData(node.ChildNodes); |
} |
} |
dsUsageData.Tables.Add(dtGameData); |
//Set Chart series Orientation Programatically |
gphGameStats.SeriesOrientation = ChartSeriesOrientation.Vertical; |
//Setup XAxis |
ApplyXaxisSettingsToChart(gphGameStats); |
gphGameStats.PlotArea.XAxis.IsZeroBased = false; |
gphGameStats.PlotArea.XAxis.Appearance.ValueFormat = Telerik.Charting.Styles.ChartValueFormat.ShortDate; |
gphGameStats.PlotArea.XAxis.AutoScale = false; |
gphGameStats.PlotArea.XAxis.Appearance.CustomFormat = "dd/MM/yy"; |
gphGameStats.PlotArea.XAxis.DataLabelsColumn = "Series0X"; |
// Setup YAxis |
gphGameStats.PlotArea.YAxis.IsZeroBased = false; |
gphGameStats.PlotArea.YAxis.Appearance.ValueFormat = Telerik.Charting.Styles.ChartValueFormat.ShortTime; |
gphGameStats.PlotArea.YAxis.AutoScale = false; |
gphGameStats.PlotArea.YAxis.Appearance.CustomFormat = "HH"; |
gphGameStats.PlotArea.YAxis.AddRange(YAxisStartTime.AddHours(2).ToOADate(), YAxisStartTime.AddHours(26).ToOADate(), 1d / 12d); |
// Setup Series |
gphGameStats.Series[0].Type = ChartSeriesType.Gantt; |
gphGameStats.Series[0].DataXColumn = "Series0X"; |
gphGameStats.Series[0].DataXColumn2 = "Series0X2"; |
gphGameStats.Series[0].DataYColumn = "Series0Y"; |
gphGameStats.Series[0].DataYColumn2 = "Series0Y2"; |
gphGameStats.Series[0].DataLabelsColumn = "Series0Label"; |
gphGameStats.Series[0].Name = "UsageData"; |
gphGameStats.Series[1].Type = ChartSeriesType.Gantt; |
gphGameStats.Series[1].DataXColumn = "Series0X"; |
gphGameStats.Series[1].DataXColumn2 = "Series0X2"; |
gphGameStats.Series[1].DataYColumn = "Series1Y"; |
gphGameStats.Series[1].DataYColumn2 = "Series1Y2"; |
gphGameStats.Series[1].DataLabelsColumn = "Series1Label"; |
gphGameStats.Series[1].Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.Nothing; |
gphGameStats.Series[2].Type = ChartSeriesType.Gantt; |
gphGameStats.Series[2].DataXColumn = "Series0X"; |
gphGameStats.Series[2].DataXColumn2 = "Series0X2"; |
gphGameStats.Series[2].DataYColumn = "Series2Y"; |
gphGameStats.Series[2].DataYColumn2 = "Series2Y2"; |
gphGameStats.Series[2].DataLabelsColumn = "Series2Label"; |
gphGameStats.Series[2].Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.Nothing; |
gphGameStats.Series[3].Type = ChartSeriesType.Gantt; |
gphGameStats.Series[3].DataXColumn = "Series0X"; |
gphGameStats.Series[3].DataXColumn2 = "Series0X2"; |
gphGameStats.Series[3].DataYColumn = "Series3Y"; |
gphGameStats.Series[3].DataYColumn2 = "Series3Y2"; |
gphGameStats.Series[3].DataLabelsColumn = "Series3Label"; |
gphGameStats.Series[3].Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.Nothing; |
//Set the Label Appearance |
gphGameStats.Series[0].Appearance.BarWidthPercent = 50; |
gphGameStats.Series[0].Appearance.LabelAppearance.Visible = true; |
gphGameStats.Series[0].Appearance.LabelAppearance.LabelLocation = Telerik.Charting.Styles.StyleSeriesItemLabel.ItemLabelLocation.Inside; |
gphGameStats.Series[0].Appearance.LabelAppearance.Position.AlignedPosition = Telerik.Charting.Styles.AlignedPositions.Center; |
gphGameStats.Series[1].Appearance.BarWidthPercent = 50; |
gphGameStats.Series[1].Appearance.LabelAppearance.Visible = true; |
gphGameStats.Series[1].Appearance.LabelAppearance.LabelLocation = Telerik.Charting.Styles.StyleSeriesItemLabel.ItemLabelLocation.Inside; |
gphGameStats.Series[1].Appearance.LabelAppearance.Position.AlignedPosition = Telerik.Charting.Styles.AlignedPositions.Center; |
//gphGameStats.Series[1].Appearance.FillStyle.MainColor = Color.Purple; |
//Set the DataSource, DataMember for the Chart |
gphGameStats.DataManager.DataSource = dsUsageData; |
gphGameStats.DataManager.DataMember = "UsageData"; |
//Bind the Data to Chart |
gphGameStats.DataBind(); |
//Update the Chart with newly added data |
gphGameStats.UpdateGraphics(); |
//Refresh the chart |
gphGameStats.Refresh(); |
} |
private void readUsageChildNodeData(XmlNodeList xmlNodeList) |
{ |
foreach (XmlNode node in xmlNodeList) |
{ |
//create the New DataRow |
dataRow = dtGameData.NewRow(); |
//Check whether the node has child nodes or not |
//if there call the same function with the child node list. |
//otherwise add the XML data to the Data row |
if (node.HasChildNodes) |
{ |
readUsageChildNodeData(node.ChildNodes); |
} |
else |
{ |
//Specify the Date formats. |
String[] formats ={ "dd/MM/yyyy", "dd/MM/yy" }; |
//set the chart start date. |
if (daysUsedCountRef == 0) |
{ |
startDate = DateTime.ParseExact(node.Attributes.GetNamedItem("Date").Value.ToString(), formats, |
System.Globalization.CultureInfo.InvariantCulture, |
System.Globalization.DateTimeStyles.NoCurrentDateDefault); |
GraphStartTime = startDate.Date.AddHours(10); |
YAxisStartTime = startDate.Date.AddHours(10); |
} |
CurrentDate = DateTime.ParseExact(node.Attributes.GetNamedItem("Date").Value.ToString(), formats, |
System.Globalization.CultureInfo.InvariantCulture, |
System.Globalization.DateTimeStyles.NoCurrentDateDefault); |
//put the Series 0 values in the row. |
dataRow["Series0X"] = CurrentDate.Date.AddHours(0).ToOADate(); |
dataRow["Series0X2"] = CurrentDate.Date.AddHours(23).ToOADate(); |
double FromMinutes = Convert.ToDouble(node.Attributes.GetNamedItem("From0").Value.ToString()); |
double ToMinutes = Convert.ToDouble(node.Attributes.GetNamedItem("To0").Value.ToString()); |
dataRow["Series0Y"] = GraphStartTime.AddHours(FromMinutes / 60).AddHours(2).ToOADate(); |
dataRow["Series0Y2"] = GraphStartTime.AddHours(ToMinutes / 60).AddHours(2).ToOADate(); |
dataRow["Series0Label"] = Math.Round((ToMinutes - FromMinutes) / 60, 1); |
FromMinutes = Convert.ToDouble(node.Attributes.GetNamedItem("From1").Value.ToString()); |
ToMinutes = Convert.ToDouble(node.Attributes.GetNamedItem("To1").Value.ToString()); |
dataRow["Series1Y"] = GraphStartTime.AddHours(FromMinutes / 60).AddHours(2).ToOADate(); |
dataRow["Series1Y2"] = GraphStartTime.AddHours(ToMinutes / 60).AddHours(2).ToOADate(); |
dataRow["Series1Label"] = Math.Round((ToMinutes - FromMinutes) / 60, 1); |
FromMinutes = Convert.ToDouble(node.Attributes.GetNamedItem("From2").Value.ToString()); |
ToMinutes = Convert.ToDouble(node.Attributes.GetNamedItem("To2").Value.ToString()); |
dataRow["Series2Y"] = GraphStartTime.AddHours(FromMinutes / 60).AddHours(2).ToOADate(); |
dataRow["Series2Y2"] = GraphStartTime.AddHours(ToMinutes / 60).AddHours(2).ToOADate(); |
dataRow["Series2Label"] = Math.Round((ToMinutes - FromMinutes) / 60, 1); |
FromMinutes = Convert.ToDouble(node.Attributes.GetNamedItem("From3").Value.ToString()); |
ToMinutes = Convert.ToDouble(node.Attributes.GetNamedItem("To3").Value.ToString()); |
dataRow["Series3Y"] = GraphStartTime.AddHours(FromMinutes / 60).AddHours(2).ToOADate(); |
dataRow["Series3Y2"] = GraphStartTime.AddHours(ToMinutes / 60).AddHours(2).ToOADate(); |
dataRow["Series3Label"] = Math.Round((ToMinutes - FromMinutes) / 60, 1); |
//Increament the daysUsedCountRef by one |
daysUsedCountRef++; |
//Add the Data row to the Datatable |
dtGameData.Rows.Add(dataRow); |
}//end of else condition |
}//end of for each loop |
}//end of the readChildNodeData |
Please look into the code and share us the comments.
I do not want to hard code the items into the values[] array. Please share a sample application to plot the discontinuos dates. I m in a big trouble now.
Thanks in advance.
Regards,
kiran
0
Hello kiran,
Please, find the answer to your question in the other support ticket.
Regards,
Evtim
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Please, find the answer to your question in the other support ticket.
Regards,
Evtim
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center