Re: urgently:How to use the control MSChart?
From: Bill Thompson (billt61_at_rgv.rr.com)
Date: 09/13/04
- Next message: Roland: "Re: CreateProcess + wait until process is initialized completelly problem"
- Previous message: Shrishail Rana: "Re: New Browser Window"
- In reply to: LeeTow: "Re: urgently:How to use the control MSChart?"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 12 Sep 2004 23:42:34 -0500
"LeeTow" <fbjlt@pub3.fz.fj.cn> wrote in message
news:#1GrUoSmEHA.2180@TK2MSFTNGP12.phx.gbl...
> I am sorry,perhaps my English is very poor.
> 1) I mean its extent is from -5 to 205 at y-axis(I can do it),look:
> {
> VARIANT var;
> m_ctlMSChart.GetPlot().GetAxis(1,var).GetValueScale().SetMaximum(205);
> m_ctlMSChart.GetPlot().GetAxis(1,var).GetValueScale().SetMinimum(-5);
> }
> and now I want to draw a line at 135 of y-axis(I cann't do it),
> if I write this sentence,it draw a line at 100 of y-axis,look:
> {
> m_ctlMSChart.GetPlot().GetAxis(1,var).GetValueScale().SetMajorDivision(2);
> }could you tell me how to draw at 135 of y-axis?
I'm sorry, no, I don't really know anything about the chart control; I
simply added the ActiveX control to a test dialog and started playing with
it. I don't really like it. The excel charts just don't look professional
to me. When I need a chart, I just code it up using device context
functions such as CreatePen(), CreateBrush(), SelectObject(), MoveTo(),
LineTo(), FillSolidRect(), etc. Plus it's easy to draw horizontal lines.
Here's some code that can draw a bar. This is off the top of my head, so it
probably has 8 or 10 bugs in it.
// it's assumed that you have specified the max/min values to be displayed
// on the axis and stored them in double m_yMax and double m_yMin
// and stored the size of the rectangle that is being drawn on in CRect
m_PlotRect.
int SomeClass::AdjustPointY(double yVal)
{
return (yVal - m_yMin) / (m_yMax - m_yMin) * m_PlotRect.height() +
m_PlotRect.bottom;
// NOTE: you could store (m_PlotRect.height() / (m_yMax - m_yMin)) as a
precalculated value in your class
// giving you something like this:
return (yVal - m_yMin) * m_PreCalc + m_PlotRect.bottom;
}
// you can create a similar function to map values for x coordinates,
// using m_PlotRect.width() and m_PlotRect.left as needed
void SomeClass::DrawBar(double y1, double y2, double x1, double x2, COLORREF
TheColor)
{
CRect BarRect;
// AdjustPointY maps a y value to a window y coordinate.
// you may want to validate that y1 >= y2
BarRect.top = AdjustPointY(y1);
BarRect.bottom = AdjustPointY(y2);
// AdjustPointX maps a x value to a window x coordinate.
// you may want to validate that x1 <= x2
BarRect.left = AdjustPointX(x1);
BarRect.right = AdjustPointX(x2);
pDC->FillSolidRect(BarRect, TheColor);
}
> 2)could you tell me in detail about 'stacking' property?
The stacking property causes the control to display the data series as a
stacked bar chart. When you display a data series in stacked bar format,
you get a single, multi-colored bar for each for each x value. The bar
changes colors at locations corresponding to the y values in the series. It
is possible you could use this style to draw a bar with two colors.
However, I believe the stacked bar goes all the way down to the x-axis,
which isn't what you need.
> Thank you very much.
>
> "Bill Thompson" <billt61@rgv.rr.com> дÈëÓʼþ
> news:e$hCWFKmEHA.2380@TK2MSFTNGP14.phx.gbl...
> > "LeeTow" <fbjlt@pub3.fz.fj.cn> wrote in message
> > news:#XcbWDGmEHA.2024@TK2MSFTNGP10.phx.gbl...
> > > 1. I write a program using vc and control mschart,but I want to not to
> > > divisive equally,for example the y-axis is from -5 to 205 and I want
to
> > > display the scale at 135,could you tell me how to do?
> > > 2. I want to display the chart that it can have different color,if the
> > > data is less than 135 it display blue,if the data is larger than 135,
> > > it display different color:it display blue from -5 to 135 and it
display
> > > red from 136 to end,could you tell me how to solve it?
> > > if you think this control cann't do it,coulu you tell what I should
use
> > > control,
> > > and you could offer the source code ,Thank you.
> > >
> > >
> >
> > I don't know exactly what you mean in 1). If you want to display
from -5
> to
> > 135, or 135 to 205, you could change the data you are using in the
graph.
> >
> > For item 2), perhaps you could use the 'stacking' property cleverly.
> >
> >
>
>
- Next message: Roland: "Re: CreateProcess + wait until process is initialized completelly problem"
- Previous message: Shrishail Rana: "Re: New Browser Window"
- In reply to: LeeTow: "Re: urgently:How to use the control MSChart?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|