HERE
leftbound = 1,rightbound = 12456
item is a object
graphlist is a collection
piccentergaraph is a picture box
For count = leftbound to rightbound
Set item = GraphList(count)
' First quartile curve
With item
ypos = (.FirstQ - .median) / .median
If count <> leftBound Then
picCenterGraph.PSet (prevPartCount, prevFirst), colBorder
picCenterGraph.Line (prevPartCount, prevFirst)-(partCount,
xaxis - ypos), colBorder
picCenterGraph.PSet (partCount, xaxis - ypos), colBorder
End If
If leftBound = rightBound Then
picCenterGraph.Line (0.95, xaxis - ypos)-(1.05, xaxis - ypos),
colBorder
End If
prevFirst = xaxis - ypos
' Third quartile curve
ypos = (.thirdq - .median) / .median
If count <> leftBound Then
picCenterGraph.PSet (prevPartCount, prevThird), colBorder
picCenterGraph.Line (prevPartCount, prevThird)-(partCount,
xaxis - ypos), colBorder
picCenterGraph.PSet (partCount, xaxis - ypos), colBorder
End If
If leftBound = rightBound Then
picCenterGraph.Line (0.95, xaxis - ypos)-(1.05, xaxis - ypos),
colBorder
End If
prevThird = xaxis - ypos
prevPartCount = partCount
partCount = partCount + 1
End With
Next
Cheers, Adam
"lavnaya" <lavanyach...@yahoo.com> wrote in message
news:e5lftb8o$GA.315@cppssbbsa04...
any further help will be really appreciated. some sample code will be
great.
thanks
venkat
Zima wrote in message ...
Private Sub Command1_Click()
With MSChart1
' Displays a 3d chart with 8 columns and 8 rows
' data.
.chartType = VtChChartType3dBar
.ColumnCount = 8
.RowCount = 8
For Column = 1 To 8
For Row = 1 To 8
.Column = Column
.Row = Row
.Data = Row * 10
Next Row
Next Column
' Use the chart as the backdrop of the legend.
.ShowLegend = True
.SelectPart VtChPartTypePlot, index1, index2, _
index3, index4
.EditCopy
.SelectPart VtChPartTypeLegend, index1, _
index2, index3, index4
.EditPaste
End With
End Sub
NOTE: This code assumes you have MSChart1 object instanciated on the form
and a buttom Command1 with the above code. Also, since MSDN example does not
explicitly define variables, remove Option Explicit statment from the module
if you have your VB settings require var declaration.
Adam
"lavnaya" <lavanyach...@yahoo.com> wrote in message
news:OIxpBm8o$GA.87@cppssbbsa04...
There are many ways you can speed up this code - basically by
stripping down everything possible inside the loop.
Firstly, it is drawing 2 points and 1 line for every point on the
graph, which is overdoing it. Graphics are by far the most
time-consuming operation (since, simplistically speaking, the
information needs sending to the graphics card; and if the picturebox
is visible, the monitor gets refreshed after every graphics
operation). Secondly, take all constants out of the loop. Also,
simplify the maths, so that "(.FirstQ - .median) / .median" becomes
".FirstQ / .median - 1"
Here is your code again, but heavily butchered. I'd wager this is 2
to 3 times faster already...
Other Ideas:
* If it is plotting only 1 pixel per line (is 12456 in pixels?), use
Pset instead of Line in the code below.
* Speed it up by another 20% using graphics API - SetPixel instead of
PSet, and LineTo/PolyLine instead of Line.
All of this may get it down to one or two seconds!
Steve.
leftbound = 1,rightbound = 12456
item is a object
graphlist is a collection
piccentergaraph is a picture box
' this will increase speed many many times
picCenterGraph.visible=false
picCenterGraph.autoredraw=true
forecolPrev=picCenterGraph.forecolor
picCenterGraph.forecolor=colBorder ' (don't ask 'Line' to set it every time)
if leftbound=rightbound then
' for speed in loops below, separate out this code
' First quartile curve
ypos = GraphList(leftbound).FirstQ / GraphList(leftbound).median - 1
picCenterGraph.Line (0.95, xaxis - ypos)-step (0.1, 0)
' Third quartile curve
ypos = GraphList(leftbound).thirdq / GraphList(leftbound).median - 1
picCenterGraph.Line (0.95, xaxis - ypos)-step(0.1, 0)
else
' to facilitate the speedy "Line -(x,y)", draw each graph separately
' First quartile curve
ypos = GraphList(leftbound).FirstQ / GraphList(leftbound).median - 1
picCenterGraph.pset (0, xaxis - ypos)' (position the graphics cursor)
For count = leftbound+1 to rightbound
ypos = GraphList(count).FirstQ / GraphList(count).median - 1
picCenterGraph.Line -(count - leftbound, xaxis - ypos)
Next
' Third quartile curve
ypos = GraphList(leftbound).thirdq / GraphList(leftbound).median - 1
picCenterGraph.pset (0, xaxis - ypos)' (position the graphics cursor)
For count = leftbound+1 to rightbound
ypos = GraphList(count).thirdq / GraphList(count).median - 1
picCenterGraph.Line -(count - leftbound, xaxis - ypos)
Next
endif
picCenterGraph.forecolor=forecolPrev
' refresh display
picCenterGraph.autoredraw=false
picCenterGraph.visible=true
picCenterGraph.refresh ' (this might not be necessary)