|
I think the judgement in function CXGraphDataSerie::Draw as following will change the curves, so you can try this
...
if (point.x != oldPoint.x )//delete this line
{//delete this line
...//keep this block
}//delete this line
...
|
|
|
|
|
How can I print two graph in one page?
|
|
|
|
|
I am looking into this as well - i would actually like 4 graphs on the same page. My first approach is simply to put 2 or 4 charts into a single view. I dont want to change any code in lib. I'll post again if i get anywhere.
chris
|
|
|
|
|
Chris:
Thank you for your help.I think this problem should correct from class CDCEx.
At first,I modify the declaration as this:
#ifdef _AFXDLL
class __declspec(dllexport) CDCEx : public CDC
#else
class __declspec(dllimport) CDCEx : public CDC
#endif
Then I add a function as following:
void CXGraph::PrintGraphEx(CDCEx *pDC,CRect clRect)
{
m_pPrintDC =pDC;
m_clPrintRect=clRect;
m_pPrintDC->m_bPrinting = true;
OnPaint();
m_pPrintDC=NULL;
}
At last, I modify the member function OnFilePrint() of view,and call PrintGraphEx in this function.
This method can print several charts in one page,but I want to get a better way to do this.Could you tell me?
|
|
|
|
|
Hey,
I've a y range from -0.1 to 1.0, in this case is the y range, which is displayed just -0.1 to .8. The problem seems to be to double comparsion in CXGraphAxis::Draw where the Axis is painted.
However, my solution is to calculate the needed steps first, than it works for the small double.
int nSteps = (m_fCurMax - m_fCurMin) / m_fStep;
double fY = m_fCurMin;
for (i = 0; i <= nSteps; i++,fY += m_fStep, fnY -= fStep)
//was: for (double fY = m_fCurMin; fY <= m_fCurMax; fY += m_fStep, fnY -= fStep)
|
|
|
|
|
Please help me to insert CXGraph in dialog.
|
|
|
|
|
I've succeeded in putting the graph in a modal dialog, but have not manged to get the menu working as it appears to be dependent on the graph being a view... I would appreciate somebody giving me a tip on how to do that...
As for putting the graph on a modal dialog... first, I created a group box as a placeholder for where I wanted the graph to be, then I put this code in OnInitDialog()
// IDC_GRID_GRAPH_RECT is my placeholder group box
CWnd* pGridGraphRectPtr = GetDlgItem(IDC_GRID_GRAPH_RECT);
pGridGraphRectPtr->GetWindowRect(&m_GridGraphRect);
ScreenToClient(m_GridGraphRect);
// the next line gets rid of the placeholder since it's not
// needed once the graph is displayed
pGridGraphRectPtr->DestroyWindow();
// This creates the graph to be displayed where the
// placeholder is...
m_ValuesGraph.Create("XGraph","", WS_CHILD | WS_VISIBLE, m_GridGraphRect, this, 1001);
I hope this helps! I keep the rect around as I'm actually swapping a few controls in the same spot based on a radio button setting, but if you're not doing that you can define the CRect locally.
|
|
|
|
|
Yes, I also have problems with menu etc in a dialog.
Did you ever manage to fix it?
Cheers,
/Martin
|
|
|
|
|
Sorry, it's been six months, so I don't remember. I ended up handing that project off to somebody else to complete, so I don't know what came of it.
|
|
|
|
|
As many before me I have to say it's an awesome library!
Though I've found a "problem":
In my app I just Create() the control in the window and wait til you load a file which will add a graph. If you (for some reason) left double click the control it:
-in debug, asserts in GetYAxis()
-in release, crashes somewhere in MFC libraries.
Are there anyone else having this problem or hav a solution?
I would really appreciate it!
|
|
|
|
|
This usually happens if you dblckick on an empty graph (no axes or curves).
|
|
|
|
|
Modify CChartPage::OnInitDialog as following:
...
if (m_pGraphAxis == NULL)
{
if(m_pGraph->GetYAxisCount()>0)
m_pGraphAxis = &m_pGraph->GetYAxis (0);
}
else
nPageSelect = 1;
if (m_pGraphDataSerie == NULL)
{
if(m_pGraph->GetCurveCount()>0)
m_pGraphDataSerie = &m_pGraph->GetCurve (0);
}
else
nPageSelect = 2;
m_pChart->m_pGraph = m_pGraph;
m_pCurve->m_pSerie = m_pGraphDataSerie;
m_pAxis->m_pAxis = m_pGraphAxis;
tabItem.mask = TCIF_PARAM | TCIF_TEXT;
tabItem.lParam = (LPARAM)m_pChart;
VERIFY(m_pChart->Create(CChartDlg::IDD, &m_Tab));
tabItem.pszText = "Chart";
m_Tab.InsertItem(0,&tabItem);
if(m_pGraph->GetYAxisCount()>0)
{
tabItem.lParam = (LPARAM)m_pAxis;
VERIFY(m_pAxis->Create(CAxisDlg::IDD, &m_Tab));
tabItem.pszText = "Axis";
m_Tab.InsertItem(1,&tabItem);
}
if(m_pGraph->GetCurveCount()>0)
{
tabItem.lParam = (LPARAM)m_pCurve;
VERIFY(m_pCurve->Create(CCurveDlg::IDD, &m_Tab));
tabItem.pszText = "Curve";
m_Tab.InsertItem(2,&tabItem);
}
...
|
|
|
|
|
sorry but this doesn't work!
|
|
|
|
|
I'm using VS.NET and a new version of XGraph received from the author last week (thanks a lot, even works with .NET).
If I doubleclicked a curve or an axis, the VS.NET run time checks reported stack corruption around the variable dc in CurveDlg::OnDrawItem() and AxisDlg::OnDrawItem(). Not very strange if one study the typecast to CDCEx* in these methods.
QuickAndDirtyFix:
In CurveDlg::OnDrawItem() and AxisDlg::OnDrawItem(), change the lines (three different places)
CDC dc;
to
CDCEx dc;
That does it for me, at least.
|
|
|
|
|
had a VERIFY problem with a horizontal line
wound up changing CXGraphAxis::SetRange and SetCurrentRange
if (fMin >= fMax) return false
to
if (fMin > fMax) return false
so far this has been a fantastic control
chris
|
|
|
|
|
The problem is still existing.I fix this as following:
Modify CXGraph::SetData
...
GetMinMaxForData(m_Data[nCurve], fxMin, fxMax,fyMin,fyMax);
if(fxMax==fxMin)
{
fxMax++;
fxMin--;
}
if(fyMax==fyMin)
{
fyMax++;
fxMin--;
}
// Set axis ranges
VERIFY(m_XAxis[nXAxis].SetRange(fxMin, fxMax));
VERIFY(m_YAxis[nYAxis].SetRange(fyMin, fyMax));
...
|
|
|
|
|
Thanks for the fix - i just encountered the problem at the same time
you posted.
I changed it a little to just nudge the max and min. Also I think you
have a typo comparing the y max and min
if (fxMax == fxMin)
{
fxMax += 0.01;
fxMin -= 0.01;
}
if (fyMax == fyMin)
{
fyMax += 0.01;
fyMin -= 0.01;
}
|
|
|
|
|
First of all: congratulation to this nice job! It's a really useful class for me.
But unfortunately I have problems with resizing the apps. My own application and your test app both hang when they are resized to smaller windows. Then they can only be killed via the task manager. (my OS is Win2k)
My other questing is, is it possible to rotate the y-axis label? And to move the x-axis label beneath the x-axis?
One again: well done!
|
|
|
|
|
Hello z_usi,
we had the same problem on W2K and Win98. After debugging the code we see, that during sizing the windows a division by zero happens.
So we fixed the problem by inserting the lines
void CXGraphAxis::AutoScale(CDCEx *pDC)
{
int nScaleTicks;
if (m_AxisKind == yAxis)
{
m_fSpareRange = (2 * m_nArcSize);
m_fMarkerSpareSize = DrawCurveMarkers(pDC, false);
int nTop = m_pGraph->m_clInnerRect.top + m_fSpareRange + m_fMarkerSpareSize;
int nBottom = m_pGraph->m_clInnerRect.bottom;
int nHeight = GetMaxLabelHeight(pDC);
int nRange = nBottom - nTop;
nScaleTicks = (int)((double) nRange / (double) nHeight);
}
else
{
m_fSpareRange = (4 * m_nArcSize);
m_fMarkerSpareSize = DrawCurveMarkers(pDC, false);
int nLeft = m_pGraph->m_clInnerRect.left;
int nRight = m_pGraph->m_clInnerRect.right - m_fSpareRange - m_fMarkerSpareSize;
int nWidth = GetMaxLabelWidth(pDC);
int nRange = nRight - nLeft;
nScaleTicks = (int)((double) nRange / (double) nWidth);
}
// new code !!!!
// Manfred Peter ... otherwise division by zero !!!!
if(nScaleTicks <= 0)
nScaleTicks = 1;
// and so on and so on
.
.
.
After that the sizing works correct.
Please let me know if that helps ..
Manfred Peter
(Alligator Company)
http://www.alligatorsql.com
webmaster@alligatorsql.com
|
|
|
|
|
Hello Peter,
thanks for your help.
But unfortunately this doesn't work too. When I inserted your line to avoid division by zero, the program XGraphTest crashes. So I changed
if(nScaleTicks <= 0) nScaleTicks = 1;
to
if(nScaleTicks == 0) nScaleTicks = 1;
Then the program doesn't crash but the problem is still there. In my opinion there must be an endless loop anywhere but I have less time at the moment to get a little bit closer to this.
So I just avoid resizing....
Chris
|
|
|
|
|
I Have a splitter with multiple views, and add a view with the control XGraph, and then, My program crash. What happen?
Victor Bravo
Venezuela
|
|
|
|
|
Can you describe the problem a bit more in detail ?
|
|
|
|
|
I use AW_CMultiViewSplitter Class (see Codeproject.com or Codeguru.com). A
splitter with multiple views, and I add ScientificGraph View and then crash.
Thanks
Victor Bravo
|
|
|
|
|
if you have a Release-Version of the Dll and Test-Application and you start the program, choose a label with a left-click, then make a right-click on a label and choose properties (only properties is available). In the properties dialog choose the background-color button. After the color-popup is open, you just have to move the mouse in it, and the application will crash!
|
|
|
|
|
I've located the problem and will post an update next week.
|
|
|
|