DIAdem Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
ULIHZ

Changing defualt legend for 2D plot

Status: Declined

Hello

Thank you for your request. We understand your suggestion but given that that just a few sponsors are supporting your entry and nearly no other customer asked this extension direct to us, we have decided to decline this suggestion. Nevertheless, we keep it in ore list of possible extensions however with a low priority and prefer to develop more frequently requested features instead. We hope you understand this.

Greetings

Walter

Every time I add some new 2D plots in my views, the default legend would be the 4 items. I do not need the X and Y ever, but would like to have some other properties instead.

It is very time consuming to click on each and every plot to make the change, while the Settings-Options-View would not let me change it. It would be nice if the default plot format can be customized.

Legend.jpg

6 Comments
MarcusP
Member

Hello ULIHZ,

 

While you cannot change the defaults for a plot type in VIEW you could however change the default layout that shows up when opening VIEW. In order to do so you simply prepare and save a layout under a unique name and enter it in the VIEW settings as default layout file.

 

In a 2nd step you could add buttons to an icon bar from which you could load different predefined layouts of your choice. DIAdem ships with an example of how to add your own buttons to the bar.

 

Hope that helps a little.

Marcus P.

ULIHZ
Member

Thanks for the hint!  In my case, I am usually doing new things rather than using preset views.  Saving a "default" will keep the format of the existing plot, but any new plots I add will still has the 4 legends. 

For example, if I want to keep the current sheets (whatever they are) and add a new sheet at the end with eight 2-D axis system plots, I would have to change each one of them to get ride of the x and y legend.

How nice will that be if I can change that!

Brad_Turpin
Trusted Enthusiast

Hi ULIHZ,

 

A workaround that you can use for now is to run a VBScript that creates its own icon in VIEW (for easy use) and sets the legend you way you want it.  Here's one I made to reconfigure the legend of every graph on the active VIEW sheet to show only the name of the Y channel being plotted.  Save this VBScript to a *.VBS file and run it in the SCRIPT panel-- you'll see a new icon show up in the VIEW icon bar.

 

OPTION EXPLICIT
Dim i, iMax, Area, LegendItems
FOR Each Area In VIEW.ActiveSheet.Areas
  IF Area.DisplayObjType = "CurveChart2D" THEN
    Set LegendItems = Area.Displayobj.LegendItems
    iMax = LegendItems.Count
    FOR i = iMax TO 2 Step -1
      Call LegendItems.Remove(i)
    NEXT ' i
  END IF ' this Area is a 2D Graph
NEXT ' Area
Call AddViewIcon()
Call WndShow("VIEW")


Sub AddViewIcon()
  Dim ButtonIDs, ButtonNames, ButtonIcons, ButtonScripts
  ButtonIDs = Array("Separator", "ChannelNameLegend")
  ButtonNames = Array("", "Channel Name Legend")
  ButtonIcons = Array("", "ANA3DBasicFunctions.ico")
  ButtonScripts = Array("", AutoActPath & AutoActName & ".VBS")
  Call AddActionObjects(ButtonIDs, ButtonNames, ButtonIcons, ButtonScripts)
  Call AddButtons(BarManager.Bars("VIEWMain"), ButtonIDs, Array(1, 1))
End Sub ' AddViewIcon()


Function AddActionObjects(ButtonIDs, ButtonNames, ButtonIcons, ButtonScripts)
  Dim j, iMax, jMax, ActionObjects, ActionObj
  ActionObjects = Array("")
  IF IsArray(ButtonIDs) THEN
    jMax = UBound(ButtonIDs)
    ReDim ActionObjects(jMax)
    ReDim Preserve ButtonNames(jMax)
    ReDim Preserve ButtonIcons(jMax)
    ReDim Preserve ButtonScripts(jMax)
    FOR j = 1 TO jMax
      IF ButtonIDs(j) <> "" THEN
        IF BarManager.ActionObjs.Exists(ButtonIDs(j)) THEN
          Set ActionObj = BarManager.ActionObjs(ButtonIDs(j))
          Call BarManager.ActionObjs.Remove(ButtonIDs(j))
        END IF
        Set ActionObjects(j) = BarManager.ActionObjs.Add(ButtonIDs(j), "CustomButton")
        ActionObjects(j).ToolTip = ButtonNames(j)
        IF Left(ButtonScripts(j), 11) = "BarManager." THEN
          ActionObjects(j).OnClickCode.Code = ButtonScripts(j)
        ELSE
          ActionObjects(j).OnClickCode.Code = "Call ScriptStart(""" & ButtonScripts(j) & """)"
        END IF
        ActionObjects(j).Picture = ButtonIcons(j)
      END IF ' ButtonIDs(j) <> ""
    NEXT ' j
  END IF ' IsArray(ButtonIDs)
AddActionObjects = ActionObjects
End Function ' AddActionObjects()


Function AddButtons(Bar, ButtonIDs, ButtonFlags)
  Dim j, iMax, jMax, Buttons
  Buttons = Array("")
  IF IsArray(ButtonIDs) THEN
    jMax = UBound(ButtonIDs)
    ReDim Buttons(jMax)
    ReDim Preserve ButtonFlags(jMax)
    FOR j = jMax TO 1 Step -1
      IF Bar.UsedActionObjs.Exists(ButtonIDs(j)) THEN
        Call Bar.UsedActionObjs.Remove(ButtonIDs(j))
      END IF
    NEXT ' j
    iMax = Bar.UsedActionObjs.Count
    IF NOT Bar.UsedActionObjs(iMax).ID = "Separator" AND ButtonIDs(0) = "Separator" THEN
      Call Bar.UsedActionObjs.Add("Separator")
    END IF
    FOR j = 1 TO jMax
      IF (ButtonFlags(j)) THEN Call Bar.UsedActionObjs.Add(ButtonIDs(j))
    NEXT ' j
  END IF ' IsArray(ButtonIDs)
AddButtons = Buttons
End Function ' AddButtons()

 

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

Brad_Turpin
Trusted Enthusiast

Hey Julia,

 

I agree, so I made an item in the Favorites Menu you have that sets all the legends in the active VIEW sheet to just channel name.  You could adjust that as desired for your purposes.

 

I still support this request for non-programming DIAdem users.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

Walter_Rick
NI Employee (retired)
Status changed to: Declined

Hello

Thank you for your request. We understand your suggestion but given that that just a few sponsors are supporting your entry and nearly no other customer asked this extension direct to us, we have decided to decline this suggestion. Nevertheless, we keep it in ore list of possible extensions however with a low priority and prefer to develop more frequently requested features instead. We hope you understand this.

Greetings

Walter

User002
Not applicable

This would be a good feature. I find myself manually changing legends a lot.

 

I'm trying out Brad's script.