Author Topic: Chart by array only displays 12:00am  (Read 2228 times)

Aeter

  • Newbie
  • *
  • Posts: 4
    • View Profile
Chart by array only displays 12:00am
« on: January 09, 2018, 10:15:20 AM »
I am using 3.99x chart by array and wanted to use Time on X axis, so I changed XValueType to Time, but it only display 12:00AM  over and over. I have searched and have seen solutions for chart by sampling by not by time.   

Thank you

Phrog30

  • Guest

Aeter

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Chart by array only displays 12:00am
« Reply #2 on: January 10, 2018, 09:02:47 AM »
Thanks for the link .  I tried using the suggestion but I do not have much experience in this type of programming  so i'm not sure where to insert that line. If you can steer me in the right direction I would appreciate it very much.     

Thanks

bachphi

  • Hero Member
  • *****
  • Posts: 671
    • View Profile
Re: Chart by array only displays 12:00am
« Reply #3 on: January 10, 2018, 10:43:09 AM »
There is no need for programming. go into ChartArea - Axes - X Axis - Label Style - Format to HH:mm:ss
and this:

http://advancedhmi.com/forum/index.php?topic=1067.msg5588#msg5588
« Last Edit: January 10, 2018, 11:42:25 AM by bachphi »
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

Aeter

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Chart by array only displays 12:00am
« Reply #4 on: January 10, 2018, 11:20:53 AM »
I see the line of code is in the ChartBySampling   But I cant see anything like that in ChartByArray

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: Chart by array only displays 12:00am
« Reply #5 on: January 10, 2018, 05:56:47 PM »
In the Visual Studio Designer, when you open the MainForm and click the ChartByArray control then look in the Properties window on the right (just like the attached picture shows).

That is where you follow the flow of ChartAreas - Axes - X Axis - Label Style - Format (or eventually make changes to Series or Legends or ...).

Whatever control you might be using on the form, you should familiarize yourself with that control's properties which are shown in the "Properties" window.
By changing the properties you would be manipulating the control's appearance / behavior.

This ChartByArray control is not designed in the same way as ChartBySampling control, so suggested actions should not be sufficient to make it show the current time on the X axis.

You can try replacing the stock ChartByArray control with the attached one to see if that comes any closer to what you want to have displayed.

Refreshing of the chart can be done by using one of the following approaches:
     
     ** with the PLC, by assigning an address to the PLCAddressRefreshAllPoints property
     ** with additional code, which would manipulate the RefreshAllPoints property, provided no address was entered in the PLCAddressRefreshAllPoints property
     ** automate the refresh by un-commenting the code inside the Region "Subscribing and PLC data receiving", as marked, provided no address was entered in the PLCAddressRefreshAllPoints property. The PollRateOverride of the driver itself could be set to 1000 for this automated example.
« Last Edit: January 11, 2018, 10:52:32 PM by Godra »

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: Chart by array only displays 12:00am
« Reply #6 on: January 11, 2018, 06:08:09 PM »
I might have misunderstood to a degree all the confusion related to code and/or your knowledge of the properties.

Still, what was suggested in my previous post and was related to properties, should be taken as general approach to working with controls.

The original ChartByArray code lines that start with "Me.Series(ItemIndex).Points.Add" could have been possibly modified to include time, as bachphi suggested in the link he provided. Such modification would be applicable to that particular project.

The modified ChartByArray control attached in my previous post was updated to actually observe the ChartAreas - Axes - X Axis - Label Style - Format field.

If the above mentioned field is left empty then, depending on the XValueType selected (Time, Date or DateTime), one of the corresponding formats will be used:
     ** HH:mm:ss
     ** dd/MM/yyyy
     ** dd/MM/yyyy HH:mm:ss

For multiple series, it is sufficient to specify the XValueType for one of them only.
« Last Edit: January 11, 2018, 10:59:07 PM by Godra »

Aeter

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Chart by array only displays 12:00am
« Reply #7 on: January 12, 2018, 09:45:16 AM »
Godra

Thank you very much for you solution.  Time  for x-axis is now working correctly, when set from Series -> Collection -> XValueType = Time.

Previously  the same setting would only display 12:00 for every data point

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: Chart by array only displays 12:00am
« Reply #8 on: January 12, 2018, 11:02:12 AM »
As suggested, the latest attached modified ChartByArray control now observes the ChartAreas - Axes - X Axis - Label Style - Format field.

You should be able to put any format in this field instead of changing it in the code.

You can check the attached picture for some formats but definitely check this link for all available standard and custom formats:

https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings