• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 444
  • Last Modified:

Two overlapping components

Can I have two charts on my form, both overlapping, by having only one visible at a time ? At design time I would make the first chart invisible before adding the second. At run time a button would control which is visible. Both TCharts would be completely overlapping, in the same exact position. There isn't room on my form for both charts to exist at the same time.
1 Solution
Would you clarify your question a little bit?

Because my mind is telling me that this is the answer ( even though rationally it isn't ):

Creating visual components at runtime:

  C: TMyVisualComponent;
  C := TMyVisualComponent.Create(Self);
  C.Left := 100;
  C.Top := 100;
  C.Width := 400;
  C.Height := 300;
  C.Visible := True;
  C.Parent := Self; //Any container: form, panel, ...

  C.MyProperty := MyValue,

Open in new window

Or by setting the first chart visible at design time and then setting it to false by a button click event.
Sinisa VukCommented:
For such thing TPageControl is good enough. Add two pages add charts to same position on each page, hide Tabs. In design or runtime you can easily set ActivePage to be visible.
Geert GOracle dbaCommented:
using TChart, you can add multiple series

when adding the first series you typically calculate the min and max values for x and y
an example: cpu usage versus number of users connected to a database
the cpu usage is from 0% to 100%
the number of users is from 0 to ???, by day about 1000, by night about 50

in the legend an indication is required of how the 2 graphs relate to each other
the cpu usage is easy > the height of the graph is the percentage > 0 to 100
for the users an estimate of 1200 max users would be 100%

example data:
cpu: 86%
actual users: 700 > value (or height) calculated in the graph: 700/1200*100=58.33%

if you make a dependency like this, it's possible to show multiple values graphs in 1 chart
typical example: average speed and altitude over distance during bike race
ChLaAuthor Commented:
TPageControl looks like a great solution.  Thank you.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now