• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 561
  • Last Modified:

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?
0
learn
Asked:
learn
  • 9
  • 5
  • 2
1 Solution
 
learnAuthor Commented:
Edited text of question.
0
 
MirkwoodCommented:
Goto project/Components
Add Microsoft Chart Control

Use the chart control
0
 
MirkwoodCommented:
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

0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
learnAuthor Commented:
Sorry, I guess that is from VB6, I have got only VB5 :-(
0
 
mark2150Commented:
M$Chart control is a *DOG*. It has no PRINT method.

You can plot whatever you want in a standard picture box.

Use the .Scale property to set the units to what is convienient for your data. Typically +- 10% for a margin.

Once you have that you can plot points with a .Line or .Circle command. Change the .ForeColor and .FillStyle properties to make different types of blips for each data set.

Write me direct and I'll send you some code. You can also see plenty of examples on my web page:

www.cyberchute.com/rvbus/madmark

M
0
 
learnAuthor Commented:
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
0
 
mark2150Commented:
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
0
 
learnAuthor Commented:
Hi mark2150,

OK, can you set a vertical axis name for the chart :-)
0
 
learnAuthor Commented:
I meant put a vertical text string as the name of the vertical axis (say for Y coordinates).
0
 
mark2150Commented:
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
0
 
learnAuthor Commented:
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 :-(
0
 
learnAuthor Commented:
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
0
 
mark2150Commented:
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
0
 
learnAuthor Commented:
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 :-)
0
 
mark2150Commented:
I think this is more to do with the printers capabilities than with VB.

M
0
 
learnAuthor Commented:
I would choose mark2150's suggestions as the answer....
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 9
  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now