TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
-
isetUser
- Newbie
- Posts: 8
- Joined: Thu Jan 19, 2023 12:00 am
Post
by isetUser » Fri Jun 02, 2023 1:23 am
now I want to create vertical lines ,i used CursorTool . this line is Control line
Code: Select all
var cuTool =new Steema.TeeChart.Tools.CursorTool(tChart.Chart)
{
Style = CursorToolStyles.Vertical,
FollowMouse = false,
};
cuTool.Pen.Color = Color.Red;
cuTool.Pen.Visible = true;
chart.xaxis is datetime .
i want cuTool.xvalue binding datatime For example cuTool.xvalue = datetime.now;
but cuTool.xvalue need double
can i use CursorTool to create vertical lines ?
If not, what can I do
-
Attachments
-
- uTools_1685668154622.png (39.37 KiB) Viewed 6294 times
-
isetUser
- Newbie
- Posts: 8
- Joined: Thu Jan 19, 2023 12:00 am
Post
by isetUser » Mon Jun 05, 2023 12:18 am
Code: Select all
var cuTool = new Steema.TeeChart.Tools.CursorTool(tChart.Chart)
{
Style = CursorToolStyles.Vertical,
FollowMouse = false,
};
cuTool.Pen.Color = Color.Red;
cuTool.Pen.Visible = true;
DateTime dateTime = DateTime.Now.AddDays(-60);
cuTool.XValue = dateTime.ToOADate();
(dateTime.ToOADate())this value can not Assign to XValue
The value of xvalue is 0
-
Christopher
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Post
by Christopher » Mon Jun 05, 2023 9:03 am
Hello,
isetUser wrote: ↑Fri Jun 02, 2023 1:23 am
(dateTime.ToOADate())this value can not Assign to XValue
The value of xvalue is 0
Yes, as the Cursor Tool is designed more for user interactivity, to get it to draw statically means having to render the chart first with
For example:
Code: Select all
Line _line1;
public Form1()
{
InitializeComponent();
_line1 = new Line(tChart1.Chart);
var now = DateTime.UtcNow;
var rnd = new Random();
for (int i = 0; i < 30; i++)
{
_line1.Add(now.AddMinutes(i), rnd.NextDouble());
}
var cuTool = new Steema.TeeChart.Tools.CursorTool(tChart1.Chart)
{
Style = CursorToolStyles.Vertical,
FollowMouse = false,
};
cuTool.Pen.Color = Color.Red;
cuTool.Pen.Visible = true;
tChart1.Draw();
var val = _line1.XValues[10];
tChart1.Text = $"TeeChart, Time: { DateTime.FromOADate(val).ToLongTimeString() }";
cuTool.XValue = val;
}
Which gives us:
- Screenshot from 2023-06-05 11-02-56.png (111.33 KiB) Viewed 6228 times