|
|
Rank: Newbie Groups: Member
Joined: 1/17/2011 Posts: 8 Location: Florida
|
I'm wondering if I can create
an XYPlot in vba with values from an array.
I have populated two arrays, one with x values and one with y values. The values came from
the display (Element Relative Values)
i.e., ThisDisplay.Label1.GetValue(vrDate, vrStatus)
I have looked at vCampus threads and see that you can manipulate XYPlots....
Dim xyDef As XYDefinition
Set xyDef = ThisDisplay.XYPlot1.GetDefinition
For rr = 1 To 27
**Now I'd like to add 27 x and y values to the XYPlot**
Next
Does anyone have any suggestions?
|
|
|
|
|
OSIsoft vCampus is a subscription-based, online offering that consists of providing everything people need to develop applications on the PI System. We invite you to take a "tour" of the OSIsoft Virtual Campus - also feel free to consult the FAQ or contact OSIsoft vCampus for more details.
|
|
|
Rank: Administration
 Groups: Administration
Joined: 6/20/2008 Posts: 617 Location: Cheshire, United Kingdom.
|
Hello, Welcome to the forum. The problem you have is that you can only designate one source of data for the X-Axis, which has to be one of the common Processbook datasets (PI Point, Calculation, ODBC...). You can't pass an array of values to the control, you would need to obtain your array of values of store somewhere that can be retrieved as a Processbook dataset (e.g. Write to an Excel Workbook and retrieve via ODBC using the Excel driver). Can you not get at your data directly rather than reading from a Symbol on a display? Principal Consultant Real-Time Data Management @ Wipro Technologies
|
|
|
Rank: Newbie Groups: Member
Joined: 1/17/2011 Posts: 8 Location: Florida
|
Thanks so much for your reply and welcome. As you might imagine, the story is long...... of what I am trying to do and why I had posted this question. Ultimately, I am trying to create a radar chart (I have also seen people calling it a radial chart) with 27 axes. In addition to the number of axes, I need that information (the x,y) to come from Element Relative Data in a PI Prcessbook display. Needless to say, I'm having trouble. PI provides a radar chart already written, that has max of 8 axes and the data can come from a tag, or a constant value, but not AF Elements or attributes. So I was told that I could write a .NET Add-In using the help of templates provided in vCampus. I do not have experience with .NET, so I got the VB code for the template to work, but have been limited in coding further to create the radar chart from there. Then, I had someone send me an email with an idea. To get the x,y value that I want, (which in turn are calculations from AF data), calculate them in AF, creating an Element attribute, and then graphing that point in an x,y plot in Processbook. I was able to graph the one point, and it moves as the data is refreshed, just as I had hoped. So now, I wished to do that 26 more times. To have 26 more x,y values and create a plot with 27 points that move radially on a graph. Now I have learned from you that this is not possible because I can only have 1 value for x in an xy plot. So I'm back to the drawing board. I have also been suggested (just last night) to bring this up as a Community Project in vCampus. Maybe that is a good idea? That is my explanation. I will try to come up with a new plan, where to go from here?? Do you have any ideas?
Thanks again for your valuable time.
|
|
|
Rank: Administration
 Groups: Administration
Joined: 6/20/2008 Posts: 617 Location: Cheshire, United Kingdom.
|
Well you can just put the "Microsoft Office Chart Object" on your display and create a radar chart that way with 27 axes. I did it in about 15 minutes or so...see the image and code below as an example. All you have to do now is hook up the data retrieved from AF via the AFDataset and throw it at your series on the chart. Code: Dim i As Integer Dim sCategories(26) For i = 0 To 26 sCategories(i) = CStr(i + 1) Next i
Dim sValues1(26) For i = 0 To 26 sValues1(i) = Rnd(200) Next i Dim sValues2(26) For i = 0 To 26 sValues2(i) = Rnd(100) Next i
Dim CS As ChartSpace Set CS = ThisDisplay.ChartSpace1
Dim CH As ChChart Set CH = CS.Charts(0) CH.Type = chChartTypeRadarLineFilled 'CH.SeriesCollection.Add 0 CH.SeriesCollection(0).SetData chDimSeriesNames, CS.Constants.chDataLiteral, "Series 1" CH.SeriesCollection(0).SetData chDimCategories, CS.Constants.chDataLiteral, sCategories CH.SeriesCollection(0).SetData chDimValues, CS.Constants.chDataLiteral, sValues1 'CH.SeriesCollection.Add 1 CH.SeriesCollection(1).SetData chDimSeriesNames, CS.Constants.chDataLiteral, "Series 2" CH.SeriesCollection(1).SetData chDimCategories, CS.Constants.chDataLiteral, sCategories CH.SeriesCollection(1).SetData chDimValues, CS.Constants.chDataLiteral, sValues2 Set CH = Nothing Set CS = Nothing
 RJK Solutions attached the following image(s):  Capture.JPG (95kb) downloaded 20 time(s).Principal Consultant Real-Time Data Management @ Wipro Technologies
|
|
|
Rank: Administration
 Groups: Administration
Joined: 6/20/2008 Posts: 617 Location: Cheshire, United Kingdom.
|
In fact a vCampus Community Project could also be a great way to go. Via a .Net addin you would be able to better hook in to AF, which you can't from VBA. I had a quick play (whilst eating my lunch...) and got an example of an auto-updating radar that uses PI Points as the series where the 27 axes represent the last 27 values for those points. It is lacking a lot of checks, exception handling etc but will be a good basis for understanding how you could go about this problem. Code: Private Const SymbolName As String = "RadarChartSeries"
Private Sub RadarChartSeriesDataUpdate(ByVal TheSymbol As Symbol) If Not TheSymbol.Type = 7 Then Exit Sub If Not Left(TheSymbol.Name, Len(SymbolName)) = SymbolName Then Exit Sub Dim TheValues(26), iValues As Integer Dim PIVal As pisdk.PIValue, PIVals As pisdk.PIValues Set PIVals = pisdk.Servers.DefaultServer.PIPoints(Split(TheSymbol.GetTagName(1), "\")(3)).Data.RecordedValuesByCount("*", 27, dReverse) iValues = 0 For Each PIVal In PIVals If PIVal.IsGood Then TheValues(iValues) = PIVal.Value Else TheValues(iValues) = 0 End If iValues = iValues + 1 Next PIVal
ThisDisplay.ChartSpace1.Charts(0).SeriesCollection(CLng(Replace(TheSymbol.Name, SymbolName, "")) - 1).SetData chDimValues, ThisDisplay.ChartSpace1.Constants.chDataLiteral, TheValues End Sub
Private Sub RadarChartSeries1_DataUpdate() Call RadarChartSeriesDataUpdate(Symbols("RadarChartSeries1")) End Sub Private Sub RadarChartSeries2_DataUpdate() Call RadarChartSeriesDataUpdate(Symbols("RadarChartSeries2")) End Sub
"RadarChartSeries1" & "RadarChartSeries2" are "Value" symbols on the display configured to use PI Points. As new data arrives the corresponding "DataUpdate" event is raised, which triggers the new data to be set for the series on the radar. Principal Consultant Real-Time Data Management @ Wipro Technologies
|
|
|
Rank: Newbie Groups: Member
Joined: 9/27/2010 Posts: 7 Location: Peru
|
Dear Khris; I'm unavailable to see (upload) your jpg chart.
|
|
|
Rank: Newbie Groups: Member
Joined: 1/17/2011 Posts: 8 Location: Florida
|
RJK: I am working on the AF portion, but I did want to tell you that I REALLY appreciate your help! The chart looks great. -AL
Also, Re: "a vCampus Community Project could also be a great way to go. Via a .Net addin you would be able to better hook in to AF, which you can't from VBA" -- as there are pros and cons to everything, I understand that a .NET Add-In will not work with WebParts. Just as an FYI.
|
|
|
Rank: Administration
 Groups: Administration
Joined: 6/20/2008 Posts: 617 Location: Cheshire, United Kingdom.
|
albertopalaci41 wrote:I'm unavailable to see (upload) your jpg chart. Try now, I included it as an image as well as an upload. Principal Consultant Real-Time Data Management @ Wipro Technologies
|
|
|
Rank: Administration
 Groups: Administration
Joined: 6/20/2008 Posts: 617 Location: Cheshire, United Kingdom.
|
ALanier wrote:RJK: I am working on the AF portion, but I did want to tell you that I REALLY appreciate your help! The chart looks great. -AL
Also, Re: "a vCampus Community Project could also be a great way to go. Via a .Net addin you would be able to better hook in to AF, which you can't from VBA" -- as there are pros and cons to everything, I understand that a .NET Add-In will not work with WebParts. Just as an FYI. Cool, let us know how you get on (or need some pointers on the AF aspects). Be good to see your final result if you are able to share it. This is true, your solution will have to be based on your complete environment where you need to consider each platform. Are planning to deply the radar chart to a 'Graphic' PI web part? Principal Consultant Real-Time Data Management @ Wipro Technologies
|
|
|
Rank: Newbie Groups: Member
Joined: 1/17/2011 Posts: 8 Location: Florida
|
RJK:
OK, so I can't tell you how nice the chart is looking! It works great, just as I hoped it would. l have a small obstacle before it will look like the old Excel version. How can I make the "layer" of the Radar Chart be underneath the layer of the other circles in my drawing? I have tried layers in Processbook Display. And I have tried programatically, but there is no "Transparent" value for RGB, or vb, like vbYellow, vbWhite.
These don't work:
CH.Interior.Color = None CH.Interior.BackColor.Transparency = 0.5 CH.Interior.FillType = ChartFillStyleEnum.chNone .........= OWC.XlColorIndex.xlColorIndexNone CH.Interior.BackColor = Nothing ....and so on. I feel I've tried everything.
Thanks again. I'm SO close!
|
|
|
Rank: Administration
 Groups: Administration
Joined: 6/20/2008 Posts: 617 Location: Cheshire, United Kingdom.
|
There may be a bug with the control when you have ProcessBook as the container for it. What you would normally call would be: Code: Call ChartSpace1.Interior.SetSolid (ChartSpace1.Constants.xlNone)
But this just turns the background a pale blue, as if it should have set it transparent. You may need to log either an OSIsoft TechSupport call and/or try and get some confirmation from Microsoft that it is a bug. Out of curiosity, what do the circles that you want on top of the chart represent? Principal Consultant Real-Time Data Management @ Wipro Technologies
|
|
|
Rank: Newbie Groups: Member
Joined: 1/17/2011 Posts: 8 Location: Florida
|
Good afternoon. And thanks again!
My chart is being used to model engine exhaust swirl. There are (between 18 and 35) possible axes, (fixed temperatures around the circle) and (possibilities of 10, 12, 14, 16 or even 18) chambers, which is what I have called "circles" that will move about the axes (in this case 27) as engine conditions change. The chambers-circles show up on top of the radar chart.
One thing I have been advised to do is research a little more on the "Bring to Front" and "Send to Back" menu options.
I will be doing that next, in addition to your suggestions.
Hope I hear from you again.
-AL
|
|
|
Rank: Administration
 Groups: Administration
Joined: 6/20/2008 Posts: 617 Location: Cheshire, United Kingdom.
|
Sounds like a cool project. Motor vehicle engine/exhaust swirl or some industrial engine? If motor vehicle then very cool! Well I had a good play around with the control and processbook, including using layers, arrangement (bring to front, send to back...) and some other types of code. It seems the control is always rendered on top in Run Mode - in Build Mode you can get the symbols on top but there is no point in that. I'll scratch my head a bit more to see if there is anything that can be done. Principal Consultant Real-Time Data Management @ Wipro Technologies
|
|
|
Rank: Newbie Groups: Member
Joined: 1/17/2011 Posts: 8 Location: Florida
|
Thanks for playing around with it. Yes, it's a neat graphical view, but of a Gas Turbine Engine -- fun stuff! I have also tried just about all combinations of layers, etc, and see the same thing you see. It shows up EXACTLY how I would like, but in build mode only. Thanks again!
|
|
|
|
Guest
|