How to create xy scatter chart in vb
I like to create xy scatter type chart(which is available in Excel)in vb.How to do it.
Xy scattter chart means data of 1st row on x axis and data of other rows shows curve corresponding to x axis.See excel curve to understand concept.
: I like to create xy scatter type chart(which is available in Excel)in vb.How to do it.
: Xy scattter chart means data of 1st row on x axis and data of other rows shows curve corresponding to x axis.See excel curve to understand concept.
One more question. Do you want you app to control excel and create xy scatter inside excel from it's values OR do you want your app to show the scatter in some picturebox from it's own values?
The first case should be done like this:
.ChartType = xlXYScatterLines
.SetSourceData Sheets("List1").Range("A1:B3"), xlColumns
.HasTitle = True
.ChartTitle.Characters.Text = "Name"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "X values"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Y values"
.Axes(xlCategory).HasMajorGridlines = True
.Axes(xlCategory).HasMinorGridlines = False
.Axes(xlValue).HasMajorGridlines = True
.Axes(xlValue).HasMinorGridlines = False
.HasLegend = False
End With[/code]I suppose you to have access to the excel ActiveWorkbook (or any other one)..
The second way: Create picture box Picture 1, choose the color of painted line and draw it pixel by pixel like by this method:
[code] myColor = RGB(myRed, myGreen, myBlue)
myColor = SetPixelV(Picture1.hdc, x, y, myColor)[/code]There should be usefull do something like
RealPictureX = X / Picture1.Width and the same for Y (not to draw beside the canvas)
Or, if you want just lines, you can use LineTo function
LineTo Picture1.hDC, x, y
but in this case, you have to create pen
hPen = CreatePen(PS_SOLID, 5, RGB(0, 128, 0))
SelectObject Picture1.hDC, hPen
(DeleteObject hPen on terminate)
and to set the first position
Form1.PSet (FirstX, FirstY), RGB(myRed, myGreen, myBlue)
SelectObject Picture1.hDC, hPen
Instead of Picture1.hDC you can use Form1.hDC to paint straight to the form
[purple]Don't take life too seriously anyway you won't escape alive from it![/purple]
I want my app to show the scatter in some picturebox from it's own values. or any other control but it should use only vb;i don't want to use excel. Suppose data values as follows.
I want data in A row should represent X axis values and data in B row should represent Y axis and form a corresponding curve.If possible data in C row should represent Second Y axis and form a corresponding curve.
i think now my query is clear to you.
If you can solve this problem please sent me code.
: I want my app to show the scatter in some picturebox from it's own values. or any other control but it should use only vb;i don't want to use excel. Suppose data values as follows.
: I want data in A row should represent X axis values and data in B row should represent Y axis and form a corresponding curve.If possible data in C row should represent Second Y axis and form a corresponding curve.
: i think now my query is clear to you.
: If you can solve this problem please sent me code.
So, if you want curve scatter, you have a problem because you have to know X and Y of each point.. And calculation regressive functions is complicated. VB do not have any included function for this.
gdi32.dll does. Take a look to API PolyBezier function to paint Bezier's curve. (You should test the count of input points)
Input date format is POINTAPI
Dim Point(0 to 6) As POINTAPI
Point(0).x = A(0)
Point(0.y = B(0)
Point(1).x = A(1)
Point(1).y = B(1)
Point(6).x = A(6)
Point(6).y = B(6)
PolyBezier Picture1.hDC, Point(0), CountOfPoints
Number of points is 4+n where n is 3*k, k=1, 2, 3, 4... (I have no idea how to write in english "nasobek" (multiple?).. I hope you understand this..)
I'm sorry but I don't have time to test this code and tell you more about it.. Try google
It looks like you're new here. If you want to get involved, click one of these buttons!
Assembly Code Share
Getting started in assembly
C and C++
C/C++ on Linux/Unix
C/C++ Windows API
C++ Game Development
Delphi and Kylix
Java Server Pages
Access databases and VB
Advance Visual Basic
DirectX Game dev
Newbie Game Programmers
Cooling & Overclocking
Database & SQL
Sound & Music
FreeLance Software City
C# & VB.NET School Support
Join the Team
Comments on this site
New programming languages
Off topic board
Mobile & Wireless
Operating Systems & Platforms
Witsbits Go Cloud
Embedded / RTOS
Windows CE & Pocket PC
Networking And Security
Windows 2003 Server
RUP & UML
Quality & Testing
Active Server Pages
HTML & WEB-Design
Mobile Internet & Messaging
WEB-Services / SOAP
In this Discussion