There are very few examples of Chart components, so that some users can find the clue, now I have seen a better example of my past, I will learn together with you.
examples:
The program code is as follows:
/ / -------------------------------------------------------------------------------------------- ---------------------------
#include
#pragma HDRSTOP
#include "teebasic.h"
#include
#include
/ / -------------------------------------------------------------------------------------------- ---------------------------
#pragma package (smart_init)
#pragma resource "* .dfm"
TDemoform * Demoform;
/ / -------------------------------------------------------------------------------------------- ---------------------------
__fastcall tdemoform :: TDemoform (Tcomponent * Owner)
: TFORM (OWNER)
{
}
/ / -------------------------------------------------------------------------------------------- ---------------------------
TCHART * TDEMOFORM :: thechart ()
{
String s = Notebook1-> Pages-> strings [0];
TPAGE * PAGE = static_cast
Return Dynamic_cast
}
Void TDemoform :: HorizScroll (const Double Percent)
{
Scrollaxis (Thechart () -> Topaxis, Percent;
Scrollaxis (thechart () -> Bottomaxis, Percent;
Button3-> enabled = true;
}
Void Tdemoform :: Vertscroll (const Double Percent)
{
Scrollaxis (thechart () -> leftaxis, percent;
Scrollaxis (Thechart () -> RightAxis, Percent;
Button3-> enabled = true;
}
Void TDemoform :: scrollaxis (tchartaxis * axis, const double percent)
{
Double Amount = - ((Axis-> Maximum-Axis-> minimum) / (100.0 / percent));
Axis-> setminmax (axis-> minimum-amount, axis-> maximum-amount);
}
Void __fastcall tdemoform :: ListBox1click (TOBJECT * SENDER)
{
Notebook1-> PageIndex = listbox1-> itemindex;
TMPTIMES = -1;
">";
Thechart () -> animatedzoomsteps = 4;
For (int T = 0; t
Thechart () -> Series [T] -> NumsampleValues ());
".
Checkbox1-> checked = thechart () -> View3d;
Scrollbar2-> enabled = thechart () -> view3d;
Scrollbar2-> POSITION = thechart () -> chart3dpercent;
IF (Dynamic_Cast
Scrollbar3-> Position = thechart () -> View3doptions-> Elevation;
Else
Scrollbar3-> Position = thechart () -> View3doptions-> rotation;
Scrollbar4-> Position = thechart () -> View3doptions-> Elevation;
Scrollbar3-> enabled = thechart () -> view3d;
Scrollbar4-> enabled = thechart () -> view3d;
}
/ / -------------------------------------------------------------------------------------------- ---------------------------
Void __fastcall tdemoform :: formcreate (TOBJECT * SENDER)
{
TMPTIMES = -1;
Scrollbar1-> Position = Timer1-> Interval
ComboBoX1-> itemIndex = 0;
ComboBoX2-> ItemIndex = 0;
ListBox1-> itemIndex = 0;
Listbox1click (this);
}
/ / -------------------------------------------------------------------------------------------- ---------------------------
Void __fastcall tdemoform :: Checkbox1click (TOBJECT * SENDER)
{
THECHART () -> View3d = checkbox1-> checked;
Scrollbar2-> enabled = thechart () -> view3d;
Scrollbar3-> enabled = thechart () -> view3d;
Scrollbar4-> enabled = thechart () -> view3d;
}
/ / -------------------------------------------------------------------------------------------- ---------------------------
Void __fastcall tdemoform :: CheckBox2Click (Tobject * Sender)
{
Timer1-> enabled = checkbox2-> checked;
Scrollbar1-> enabled = Timer1-> enabled;
}
/ / -------------------------------------------------------------------------------------------- ---------------------------
Void __fastcall tdemoform :: scrollbar1change (TOBJECT * Sender) {
Timer1-> Interval = scrollbar1-> position;
}
/ / -------------------------------------------------------------------------------------------- ---------------------------
Void __fastcall tdemoform :: Timer1Timer (TOBJECT * Sender)
{
Double TMPX;
Switch (Notebook1-> PageIndex) {
Case 0:
Case 3:
Case 4:
Case 6: {
For (int T = 0; t
TMPX = thechart () -> Series [T] -> XVALUES-> Value [1] -
THECHART () -> Series [T] -> XVALUES-> Value [0];
THECHART () -> Series [T] -> Delete (0);
THECHART () -> Series [T] -> Addxy (
Thechart () -> Series [T] -> XVALUES-> Last () TMPX,
Thechart () -> Series [T] -> Yvalues-> Last () Random (100) -50, "", CLTeecolor);
}
Break;
}
Case 1:
Case 2:
Case 8: {
IF (tmptimes == - 1) {
TmpSeries = random (Thechart () -> Seriescount ());
Tmpindex = random (Thechart () -> Series [TmpSeries] -> count ());
TMPTIMES = Random (10);
Tmprandom = 2 * floor ((Random (50) -25.0) .5);
}
IF (TmpSeries! = -1) {
IF (Notebook1-> PageIndex == 8) {
TbubbleSeries * s =
Dynamic_cast
TMPX = S-> RadiusValues-> Value [Tmpindex] Tmprandom
IF (tmpx> = 2) {
S-> RadiusValues-> value [tmpindex] = TMPX;
IF (Tmprandom> 0)
TMPX = S-> XVALUES-> Value [TmpIndex] 1;
Else
TMPX = S-> XVALUES-> Value [TmpIndex] -1;
S-> XVALUES-> Value [tmpinDex] = TMPX;
IF (Random (10) <5)
TMPX = S-> Yvalues-> value [tmpinDex] 50;
Else
TMPX = S-> Yvalues-> value [tmpinDex] -50;
S-> Yvalues-> Value [Tmpindex] = TMPX;
}
Else tmptimes = 0;
}
Else
Thechart () -> Series [TmpSeries] -> MandatoryValuelist () -> Value [tmpindex] = thechart () -> Series [TmpSeries] -> MandatoryValuelist () -> Value [TmpIndex] Tmprandom;
TMPTIMES -
"." -> repaint ();
}
Break;
}
Case 5: {
Tpieseries * s = Dynamic_Cast
S-> Rotate (358);
Break;
}
}
}
/ / -------------------------------------------------------------------------------------------- ---------------------------
Void __fastcall tdemoform :: Button2Click (TOBJECT * SENDER)
{
CLOSE ();
}
/ / -------------------------------------------------------------------------------------------- ---------------------------
Void __fastcall tdemoform :: bitbtn1click (Tobject * Sender)
{
Thechart () -> zoompercent (120);
Button3-> enabled = true;
}
/ / -------------------------------------------------------------------------------------------- ---------------------------
Void __fastcall tdemoform :: bitbtn2click (TOBJECT * SENDER)
{
Thechart () -> zoompercent (80);
Button3-> enabled = true;
}
/ / -------------------------------------------------------------------------------------------- ---------------------------
Void __fastcall tdemoform :: SpeedButton1click (Tobject * Sender)
{
HorizScroll (10);
}
/ / -------------------------------------------------------------------------------------------- ---------------------------
Void __fastcall tdemoform :: SpeedButton4Click (TOBJECT * Sender)
{
HorizScroll (-10);
}
/ / -------------------------------------------------------------------------------------------- ---------------------------
Void __fastcall tdemoform :: SpeedButton2Click (TOBJECT * SENDER)
{
VERTSCROLL (-10);
}
/ / -------------------------------------------------------------------------------------------- ---------------------------
Void __fastcall tdemoform :: SpeedButton3Click (TOBJECT * SENDER)
{
VERTSCROLL (10);
}
/ / -------------------------------------------------------------------------------------------- ---------------------------
Void __fastcall tdemoform :: Checkbox3Click (Tobject * Sender)
{
Tpieseries * s = Dynamic_cast
}
/ / -------------------------------------------------------------------------------------------- ---------------------------
Void __fastcall tdemoform :: ComboBox1click (Tobject * Sender)
{
TCUSTombarseries * S = Dynamic_cast
Tcombobox * cb = Dynamic_cast
S-> Multibar = TMULTIBAR (CB-> itemIndex);
}
/ / -------------------------------------------------------------------------------------------- ---------------------------
Void __fastcall tdemoform :: scrollbar2change (TOBJECT * SENDER)
{
Thechart () -> chart3dpercent = scrollbar2-> position;
}
/ / -------------------------------------------------------------------------------------------- ---------------------------
Void __fastcall tdemoform :: series28getmarktext (tChartSeries * sender,
INT ValueIndex, Ansistring & MarkText)
{
IF (valueIndex == 3)
Marktext = "USA";
Else IF (valueIndex == 5)
MarkText = "UK";
Else IF (valueIndex == 7)
Marktext = "germany";
Else
MarkText = ""
}
/ / -------------------------------------------------------------------------------------------- ---------------------------
Void __fastcall tdemoform :: Button3Click (TOBJECT * SENDER)
{
".
Button3-> enabled = false;
}
/ / -------------------------------------------------------------------------------------------- ---------------------------
Void __fastcall tdemoform :: CheckBox4click (Tobject * Sender)
{
Series11-> stairs = checkbox4-> checked;
Series12-> stairs = checkbox4-> checked;
}
/ / -------------------------------------------------------------------------------------------- ---------------------------
Void __fastcall tdemoform :: FormShow (TOBJECT * SENDER)
{
Timer1-> enabled = true; // <- start animation
}
/ / -------------------------------------------------------------------------------------------- --------------------------- void __fastcall tdemoform :: scrollbar3change (TOBJECT * SENDER)
{
IF (scrollbar3-> enabled)
THECHART () -> View3dOptions-> Orthogonal = FALSE;
IF (Dynamic_Cast
Thechart () -> View3doptions-> elevation = scrollbar3-> position;
Else
Thechart () -> View3dOptions-> rotation = scrollbar3-> position;
}
/ / -------------------------------------------------------------------------------------------- ---------------------------
Void __fastcall tdemoform :: scrollbar4change (TOBJECT * SENDER)
{
IF (scrollbar4-> enabled) {
THECHART () -> View3dOptions-> Orthogonal = FALSE;
Thechart () -> View3doptions-> elevation = scrollbar4-> position;
}
}
/ / -------------------------------------------------------------------------------------------- ---------------------------