Legend for AChart control?

John K.
Bacau,

Jun 7, 2011
55 Posts

0  |  0  

Re: Legend for AChart control?

Hi there! I am plotting several signals on a chart (2 or more) and I'd like to represent a legend with the signals plotted and their names. Can anyone please help me with some info about how to do this?

Solution Available
Victor B.
Lake Forest, CA

Jun 7, 2011
93 Posts

1  |  0  

Re: Legend for AChart control?

I solved this problem by creating an APanel object next to my chart named 'pnlLegend'.  Then, after the chart's plots were created and populated, I called this procedure.  It loops through the plots in 'cht1' and dynamically creates labels with the color and name of each plot:

ob: Object                     !Temporary object used for creating controls dynamically
lPlotIndex: Long               !For loop counter
lTop: Long                     !Tracks the top of the controls added to the panel
lPlotTitleLeft: Long Const = 35   !The Left value for the plot title label
lPlotColorLeft: Long Const = 10   !The Left value for the plot color label

{
  lTop=10

  for lPlotIndex=0 to cht1.PlotCount-1

    !Insert label to display plot color
    ob=Form.InsertControl("lblPlotColor"+Str(lPlotIndex), "ALabel", lPlotColorLeft, lTop, 10, 10, pnlLegend.Name)
    ob.BackColor=cht1.Plots(lPlotIndex).LineColor

    !Insert label to display plot name
    ob=Form.InsertControl("lblPlotTitle"+Str(lPlotIndex), "ALabel", lPlotTitleLeft, lTop, 50, 10, pnlLegend.Name)
    ob.Caption=cht1.Plots(lPlotIndex).Name
    
    lTop=lTop+20
  next
}

Regards,
Victor Brode

John K.
Bacau,

Jun 9, 2011
55 Posts

0  |  0  

Re: Legend for AChart control?

Thank you for your help, Victor! Have a nice day!

Best regards,

Alex J.



Please Note
You need to have a M@GIC account to participate in the Forums.
Not yet registered on our website? Click here to register today!

All content, information and opinions presented on the Marvin Test Solutions User Forums are those of the authors of the posts and messages and not Marvin Test Solutions'. All attachments and files are downloaded at your own risk. [Read More]