learn
asked on
Embed a chart.
Got numbers in two arrays: x(1 to n) and y(1 to n) in an application, want to show them in a scater chart during the application run time.
Perhaps OLE?
Only the chart, no sheet.
Dynamic: when the data in x() and y() changed, the graph will be changed.
Can you tell me how....with code?
Perhaps OLE?
Only the chart, no sheet.
Dynamic: when the data in x() and y() changed, the graph will be changed.
Can you tell me how....with code?
Goto project/Components
Add Microsoft Chart Control
Use the chart control
Add Microsoft Chart Control
Use the chart control
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
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
ASKER
Sorry, I guess that is from VB6, I have got only VB5 :-(
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
To mark2150:
Thank you.
Actually, I am using a form to draw the chart and I am thinking to past the code from the form to a ocx, or write some properties, methods and events for the form so that it can by used next time.
The problem is it needs many line styles, mark styles, line thikness, colors, number format and all the options......That is why I think it would be easier to try a OLE holding an Excel or something.
I will go to see your seb site.
Cheers.
learn
Thank you.
Actually, I am using a form to draw the chart and I am thinking to past the code from the form to a ocx, or write some properties, methods and events for the form so that it can by used next time.
The problem is it needs many line styles, mark styles, line thikness, colors, number format and all the options......That is why I think it would be easier to try a OLE holding an Excel or something.
I will go to see your seb site.
Cheers.
learn
Whatever works. But i've found drawing is not hard to code and you can use the same routine for screen rendering and for printing so I don't bother with going to an extra 3rd party control when my code runs fine.
M
M
ASKER
Hi mark2150,
OK, can you set a vertical axis name for the chart :-)
OK, can you set a vertical axis name for the chart :-)
ASKER
I meant put a vertical text string as the name of the vertical axis (say for Y coordinates).
Ummm, Don't know if you can make text run uphill. You can do a stacked series of letters:
L
I
K
E
T
H
I
S
But that is not the same. Never tried to make the text run uphill. Ummm, In thinking about it I don't seem to recall a text rotation command.
You *might* be able to do it by writing the text to a (hidden) graphic and using API calls to rotate the graphic and then BitBlT the rotated graphic into the graph, but that would be a *LOT* of work
M
L
I
K
E
T
H
I
S
But that is not the same. Never tried to make the text run uphill. Ummm, In thinking about it I don't seem to recall a text rotation command.
You *might* be able to do it by writing the text to a (hidden) graphic and using API calls to rotate the graphic and then BitBlT the rotated graphic into the graph, but that would be a *LOT* of work
M
ASKER
To mark2150:
hahaha, It looks too difficult?
How about the API functions DrawText and DrawTexEx? I used them sometimes ago but haven't got any explanation or help for them :-(
hahaha, It looks too difficult?
How about the API functions DrawText and DrawTexEx? I used them sometimes ago but haven't got any explanation or help for them :-(
ASKER
To mark2150:
Article ID: Q154515
HOWTO: Print Rotated Text Using Win32 API
Unfortunately, the rotated text looks not very nice, though it is similar in Excel.
Cheers.
Learn
Article ID: Q154515
HOWTO: Print Rotated Text Using Win32 API
Unfortunately, the rotated text looks not very nice, though it is similar in Excel.
Cheers.
Learn
That's what I was afraid of. The text isn't "text" any more, it's a pattern of bits that happens to LOOK like text when viewed at the screen resolution. Real "text" will render itself on the output device at the best resolution that device is capable of whereas a block of bits is just that, a block of bits and will NOT scale as the printer resolution increases. The vertical text:
L
I
K
E
T
H
I
S
is "real text" and will render well at any printer resolution. So the Q boils down to can you live with "stacked letters" that look *good* or do you want rotated text that looks like crap? Me, I'll take the stacked letters that looks good.
M
L
I
K
E
T
H
I
S
is "real text" and will render well at any printer resolution. So the Q boils down to can you live with "stacked letters" that look *good* or do you want rotated text that looks like crap? Me, I'll take the stacked letters that looks good.
M
ASKER
To mark2150:
Why there is no rotated font? at lease the vertical one!
Perhaps we may create some homemade font? Is that difficult? just for a few font type :-)
Why there is no rotated font? at lease the vertical one!
Perhaps we may create some homemade font? Is that difficult? just for a few font type :-)
I think this is more to do with the printers capabilities than with VB.
M
M
ASKER
I would choose mark2150's suggestions as the answer....
ASKER