0
votes

I am trying to add scroll tool to my chart but not able to do that . Below is the code

{
m_chart1.ClearChart();
m_chart1.GetPage().SetMaxPointsPerPage(5);  
wchar_t tmp[30]={0};
wchar_t t[10] = L"T%d";
int i = 0;
m_chart1.AddSeries(1);
wsprintf(tmp,t,i);
m_chart1.Series(i).SetColor(RGB(rand(),rand(),rand()));
m_chart1.Series(i).SetLegendTitle(tmp);  
m_chart1.Series(i).FillSampleValues(100);
m_chart1.Series(i).GetMarks().SetVisible(false);
m_chartNavigation.SetChartLink(m_chart1.GetChartLink());
m_chart1.GetAspect().SetView3D(false);
m_chart1.GetTools().Add(22);
_variant_t vardata;
VariantInit (&vardata);
vardata.vt = VT_BYREF;
vardata.byref = &m_chart1.GetAxis().GetBottom();
m_chart1.GetTools().GetItems(0).GetAsAxisScroll().SetAxis(vardata);
m_chart1.GetTools().GetItems(0).SetActive(true);
}

Code Compiles properly but arrow is not displayed on Axis. Thanks Akshay

2
Hi Yeray, Thanks for the reply but actually I have tried both AxisArrow(2) AxisScroll(22) nothing is working for me. Please check the content of vardata whether the data which I am storing in varient is right. Thanks AkshayAkshay Bhalla

2 Answers

2
votes

Code Compiles properly but arrow is not displayed on Axis

I'm not sure about what m_chartNavigation from your code is. Is it a ChartPageNavigator? Note this component adds a navigation bar separate from the chart.

If you want to show some arrows to scroll the chart, you should use the AxisArrow tool, not the AxisScroll tool, that is the 2, not the 22.

m_chart1.GetTools().Add(2);
m_chart1.GetTools().GetItems(0).GetAsAxisArrow().SetAxis(vardata);
0
votes

I have modified your code, so the AxisArrow tool works in correct way and allow you do scroll of the axis as you want. Therefore, please see next code and consider the indications, because you can use the code without problems.

Considerations:

1.- Check if you there are all classes in the folder as you have your project. If you doesn't have all classes you must copy these from folder Uitilities\New VC Classes as you find, in the folder where you installed TeeChartActivex. The folder is similar as next C:......\TeeChart Pro v2012 ActiveX Control\Utilities\New VC Classes

2.- Use next includes in your code:

#include "stdafx.h"
#include "XXXXX.h"
#include "XXXXX.h"

#include "series.h"
#include "axes.h"
#include "axis.h"
#include "TeeChartDefines.h"
#include "aspect.h"
#include "zoom.h"
#include "scroll.h"
#include "environment.h"
#include "marks.h"
#include "page.h"
#include "lineseries.h"
#include "axisarrowtool.h"
#include "toollist.h"
#include "tools.h"
#include "comutil.h"
#include "afxdisp.h"

3.- The code has been made on the OnInitDialog() of the project.

Code:

Could you tell us if next code works in your end?

{
.
.
.
// TODO: Add extra initialization here
    m_tChart1.ClearChart();
    long index = m_tChart1.AddSeries(scLine);
    m_tChart1.GetAspect().SetView3D(false);
    m_tChart1.GetPage().SetMaxPointsPerPage(5);
    m_tChart1.Series(index).SetColor(RGB(rand(),rand(),rand()));
    m_tChart1.Series(index).SetLegendTitle("Hello");  
    m_tChart1.Series(index).FillSampleValues(100);
    m_tChart1.Series(index).GetMarks().SetVisible(false);
    long index1 = m_tChart1.GetTools().Add(tcAxisArrow); 
    //SetAxisArrow Tool to do scroll.
    m_tChart1.GetTools().GetItems(index1).GetAsAxisArrow().SetAxis(COleVariant(short(atBottom))); 
 // TODO: Add extra initialization here
    return TRUE;  // return TRUE  unless you set the focus to a control
}

I hope will helps.

Thanks, Sandra.