Author Topic: ChartBySampling X Axis Formatting  (Read 3100 times)

anthony92

  • Newbie
  • *
  • Posts: 22
    • View Profile
ChartBySampling X Axis Formatting
« on: January 16, 2017, 10:28:46 PM »
I am having difficulties setting up the chart with an X axis that will follow the active data points streaming into the chart, while also maintaining a fixed chart width. (I would like the chart to show 20 data points even if they are empty at one time without the X axis scaling or growing as it fills.)

Right now as data streams in the chart grows to the max active point scale and then the chart stops scrolling with the data and the points go out of screen. In addition to this the X axis values do not update if it overrides when time is used.

What parameters to I need to use for a line series and chart area to achieve what I described above.


Img: Line moving right

Version: 399s

Off Topic: With MessageDisplayByBit is it intentional to have to use another ClXCom port. (It seems to stop the other components from polling the PLC if MDBB is on the same Com Component.) This component will also not work unless PLCAddress... is defined in the designer to a random value. (I usually set all components in code on ini.)

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: ChartBySampling X Axis Formatting
« Reply #1 on: January 16, 2017, 10:38:31 PM »
If I understand correctly, you can "pre-set" the number of points on the chart like this:

- With the Chart Selected, in the Properties Window, select the Series and click the ellipsis button to open the Series Collection Editor window
- In the properties of that window, find the Points property, click in it, then click the ellipsis button to open the Data Point Collection Editor window
- Click the Add button to set the number of points you want the chart to start with

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: ChartBySampling X Axis Formatting
« Reply #2 on: January 16, 2017, 10:42:42 PM »
Scratch that method because it does not work when using Time format for the X-Axis

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: ChartBySampling X Axis Formatting
« Reply #3 on: January 16, 2017, 11:06:44 PM »
Off Topic: With MessageDisplayByBit is it intentional to have to use another ClXCom port. (It seems to stop the other components from polling the PLC if MDBB is on the same Com Component.) This component will also not work unless PLCAddress... is defined in the designer to a random value. (I usually set all components in code on ini.)
There seems to be a problem in the MessageDisplayByBit.vb code.

Edit MessageDisplayByBit.vb and go to line 197, then change the code to this:

           If Not String.IsNullOrEmpty(m_PLCAddressValues) Then
                NotificationIDValue = m_ComComponent.Subscribe(m_PLCAddressValues, m_PLCNumberOfElements, 500, AddressOf PolledDataReturned)
            End If

anthony92

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: ChartBySampling X Axis Formatting
« Reply #4 on: January 17, 2017, 12:53:22 AM »
Thank you for the quick response.

Is there a way I could set the x-axis text myself on the plc sample for each point?

In case my original post was confusing, I am trying to achieve something like the left side of this image. But with much longer samples (1 every 10 seconds). Disregard the multiple series in the image.



I added that code to the MessageDisplayByBit and it fixed that PLCAddressValue empty issue.
The coms of it still require a seperate component however.
« Last Edit: January 17, 2017, 03:01:22 AM by anthony92 »

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: ChartBySampling X Axis Formatting
« Reply #5 on: January 17, 2017, 07:37:13 PM »
I added that code to the MessageDisplayByBit and it fixed that PLCAddressValue empty issue.
The coms of it still require a seperate component however.
I just tried this out with a single EthernetIPforCLXCom and it is working as expected. I added a MessageDisplayByBit and 2 BasicLabels. They all update as normal.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: ChartBySampling X Axis Formatting
« Reply #6 on: January 20, 2017, 03:04:40 AM »
Is there a way I could set the x-axis text myself on the plc sample for each point?
If you edit ChartBySampling.vb and go to line 303, you can change it to something like this:

                MyBase.Series(index).Points.AddXY("A", (m_PLCAddressItems(index).GetScaledValue(d)))

anthony92

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: ChartBySampling X Axis Formatting
« Reply #7 on: February 05, 2017, 08:17:32 PM »
If I understand correctly, you can "pre-set" the number of points on the chart like this:

- With the Chart Selected, in the Properties Window, select the Series and click the ellipsis button to open the Series Collection Editor window
- In the properties of that window, find the Points property, click in it, then click the ellipsis button to open the Data Point Collection Editor window
- Click the Add button to set the number of points you want the chart to start with

Is there a way to do this via code?

I have tried using the below code but it does not seem to work.
Code: [Select]
        With chrPktLen.DataManipulator
            .InsertEmptyPoints(1, IntervalType.Number, "Packet Length Average")
            .InsertEmptyPoints(1, IntervalType.Number, "Lane 1")
            .InsertEmptyPoints(1, IntervalType.Number, "Lane 2")
            .InsertEmptyPoints(1, IntervalType.Number, "Lane 3")
            .InsertEmptyPoints(1, IntervalType.Number, "Lane 4")
        End With

Also setting a new PLCAddress on a series does not seem to work when the form is loading.

Code: [Select]
chrPktLen.PLCAddressItems(1).PLCAddress = GlobalVar.PLCVarLoc & "PackLenMM[0]"

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: ChartBySampling X Axis Formatting
« Reply #8 on: February 05, 2017, 09:18:03 PM »
The chart has no mechanism to change subscriptions when the PLCAddressItems are changed. Whatever is there on startup is pretty much what it is locked into. The code can be changed to accommodate. If you look at the code around line 240, you will see the SubscribeToComDriver where it establishes the subscriptions to the Items.

anthony92

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: ChartBySampling X Axis Formatting
« Reply #9 on: February 05, 2017, 10:26:37 PM »
Thanks Archie. I made a work around by making the chart invisible at first and then setting it to visible after setting the PLCAddress.

I'm still having issue with adding the code necessary to add 60 empty points for all series on the chart rather than doing this by hand. This is more for a visual appearance so the chart loads from right to left.

Edit: I was able to add empty points using the following code. Hopefully someone will find it useful.
Code: [Select]
' Fill charts with empty points
For series = 0 To 5
    For i = 0 To 59
        Dim item As DataPoint
        item = New DataPoint()
        item.IsEmpty = True
        chrPktLen.Series(series).Points.Add(item)
    Next
Next

' This introduces some issue with min max y axis values. It is best to silence these errors
chrPktLen.SuppressExceptions = True
« Last Edit: February 10, 2017, 02:09:33 AM by anthony92 »