Hi Steema,
We have use TChart.Net 2012. We have XY data in which X values are in date time format. We have created a line series to plot this data in the charts. Now our requirements is that we want to display the hours in primary axis( in 24 hours format) in the bottom and date is displaying in secondary axis in the bottom of the chart. This hours labels created on the bases of date time data.
For your reference we have attached a image.
So kindly provide the solution for same.
Thanks
Amol
Create separate bottom axis for hours format and date format at a time.
Create separate bottom axis for hours format and date format at a time.
- Attachments
-
- chart1.png (10.01 KiB) Viewed 19857 times
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: Create separate bottom axis for hours format and date format at a time.
Hello Amol,
you could base your solution on code similar to this:
Which here gives me:
you could base your solution on code similar to this:
Code: Select all
private void InitializeChart()
{
var line = new Line(_tChart.Chart);
var now = DateTime.UtcNow;
var rnd = new Random();
for (var i = 0; i < 50; i++)
{
line.Add(now, rnd.Next(1000));
now = now.AddHours(4);
}
_tChart.Axes.Bottom.Increment = (1 / 24) * 4;
_tChart.Axes.Bottom.Labels.DateTimeFormat = "HH";
_tChart.Axes.Bottom.Grid.Visible = false;
var axis = _tChart.Axes.Bottom.SubAxes.Add();
axis.Increment = 1;
axis.Labels.DateTimeFormat = "M";
axis.GetAxisDrawLabel += Bottom_GetAxisDrawLabel;
axis.Grid.DrawEvery = 1;
axis.Grid.Color = Color.Red;
}
private void Bottom_GetAxisDrawLabel(object sender, GetAxisDrawLabelEventArgs e)
{
var axis = sender as Axis;
var size = axis.CalcSizeValue(1);
e.X += size / 2;
}
Best Regards,
Christopher Ireland / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: Create separate bottom axis for hours format and date format at a time.
Hi Steema,
Thanks for the reply. We have used your code as you mentioned in your demo but i have not able to use "SubAxes" for bottom axis. The code as you mentioned in below:
var axis = _tchart.Axes.Bottom.SubAxes.Add();
Here we are using TChart Dot Net version 2012.
So kindly guide us how we use "SubAxes" for bottom.
Thanks & regards
Amol
Thanks for the reply. We have used your code as you mentioned in your demo but i have not able to use "SubAxes" for bottom axis. The code as you mentioned in below:
var axis = _tchart.Axes.Bottom.SubAxes.Add();
Here we are using TChart Dot Net version 2012.
So kindly guide us how we use "SubAxes" for bottom.
Thanks & regards
Amol
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: Create separate bottom axis for hours format and date format at a time.
Hello Amol,
you can see the code working by downloading the NuGet package from here; you can either use Visual Studio to install the package or you can download it and unzip it to access the TeeChart assemblies.
The SubAxes feature may not be a feature available in TeeChart 2012, but I am not authorized to effectively give you the source code for this new feature.
you can see the code working by downloading the NuGet package from here; you can either use Visual Studio to install the package or you can download it and unzip it to access the TeeChart assemblies.
The SubAxes feature may not be a feature available in TeeChart 2012, but I am not authorized to effectively give you the source code for this new feature.
Best Regards,
Christopher Ireland / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |