Displaying 2 straight lines

Hi,

Hope someone can tell me how to do this....

I have one set of points which form a straight line - 
these are (3.1,0), (3.1,100), (3.1,200), (3.1,300) i.e. a 
vertical line.

I have another set of points that form a straight line - 
these are (0,0), (3.1,100), (6.2,200), (9.3,300).

I have two problems displaying these:

(1) I want both lines to appear on the same graph;

(2) I want the traingle formed by the points (3.1,100), 
(3.1,300) and (9.3,300) to be shaded, as this indicates a 
surplus (for the purposes of illustration).

I would imagine there would definitely be a way to display 
both straight lines on the one graph, but what about the 
2nd probelm I have?

Many Thanks,

Gary.

0
anonymous (74722)
2/27/2004 2:36:28 PM
excel.charting 18370 articles. 0 followers. Follow

2 Replies
678 Views

Similar Articles

[PageSpeed] 0

Gary -

Here's your data sheet

  X1   Y1      X2   Y2      X3   Y3
3.1    0       0    0     3.1  300
3.1  300     9.3  300     3.1  100
                           9.3  300

X1-Y1 are for the vertical line, X2-Y2 are for the diagonal line, and 
X3-Y3 are to draw a triangle.

Select the cells containing the data and labels for X1 and Y1, and use 
the chart wizard to create an XY Scatter chart (NOT a Line chart). Right 
click on your new chart, select Source Data, Series Tab, click on the 
Add button, and use the mouse to select the X range for X2 and the Y 
range for Y2. Click Add again to add X3 and Y3.

The following macro will draw a shape based on the points in series 3:

Sub DrawAShape()
      Dim myCht As Chart
      Dim mySrs As Series
      Dim Npts As Integer, Ipts As Integer
      Dim myShape As Shape
      Dim Xnode As Double, Ynode As Double
      Dim Xmin As Double, Xmax As Double
      Dim Ymin As Double, Ymax As Double
      Dim Xleft As Double, Ytop As Double
      Dim Xwidth As Double, Yheight As Double

      Set myCht = ActiveChart
      Xleft = myCht.PlotArea.InsideLeft
      Xwidth = myCht.PlotArea.InsideWidth
      Ytop = myCht.PlotArea.InsideTop
      Yheight = myCht.PlotArea.InsideHeight
      Xmin = myCht.Axes(1).MinimumScale
      Xmax = myCht.Axes(1).MaximumScale
      Ymin = myCht.Axes(2).MinimumScale
      Ymax = myCht.Axes(2).MaximumScale

      Set mySrs = myCht.SeriesCollection(3)
      Npts = mySrs.Points.Count

      Xnode = Xleft + (mySrs.XValues(Npts) - Xmin) _
          * Xwidth / (Xmax - Xmin)
      Ynode = Ytop + (Ymax - mySrs.Values(Npts)) _
          * Yheight / (Ymax - Ymin)

      With myCht.Shapes.BuildFreeform(msoEditingAuto, Xnode, Ynode)
          For Ipts = 1 To Npts
              Xnode = Xleft + (mySrs.XValues(Ipts) - Xmin) _
                  * Xwidth / (Xmax - Xmin)
              Ynode = Ytop + (Ymax - mySrs.Values(Ipts)) _
                  * Yheight / (Ymax - Ymin)
              .AddNodes msoSegmentLine, msoEditingAuto, Xnode, Ynode
          Next
          Set myShape = .ConvertToShape
      End With

      With myShape
          .Fill.ForeColor.SchemeColor = 13 ' YELLOW
          .Line.ForeColor.SchemeColor = 12 ' BLUE
      End With
End Sub

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
http://PeltierTech.com/Excel/Charts/
_______


Gary Thomson wrote:

> Hi,
> 
> Hope someone can tell me how to do this....
> 
> I have one set of points which form a straight line - 
> these are (3.1,0), (3.1,100), (3.1,200), (3.1,300) i.e. a 
> vertical line.
> 
> I have another set of points that form a straight line - 
> these are (0,0), (3.1,100), (6.2,200), (9.3,300).
> 
> I have two problems displaying these:
> 
> (1) I want both lines to appear on the same graph;
> 
> (2) I want the traingle formed by the points (3.1,100), 
> (3.1,300) and (9.3,300) to be shaded, as this indicates a 
> surplus (for the purposes of illustration).
> 
> I would imagine there would definitely be a way to display 
> both straight lines on the one graph, but what about the 
> 2nd probelm I have?
> 
> Many Thanks,
> 
> Gary.
> 

0
jonxlmvpNO (4558)
2/27/2004 5:57:14 PM
Hi Gary,

I have posted a alternative non vba approach for obtaining the fill area.
(http://www.andypope.info/ngs/ng27.htm)

Cheers
Andy

Gary Thomson wrote:

> Hi,
> 
> Hope someone can tell me how to do this....
> 
> I have one set of points which form a straight line - 
> these are (3.1,0), (3.1,100), (3.1,200), (3.1,300) i.e. a 
> vertical line.
> 
> I have another set of points that form a straight line - 
> these are (0,0), (3.1,100), (6.2,200), (9.3,300).
> 
> I have two problems displaying these:
> 
> (1) I want both lines to appear on the same graph;
> 
> (2) I want the traingle formed by the points (3.1,100), 
> (3.1,300) and (9.3,300) to be shaded, as this indicates a 
> surplus (for the purposes of illustration).
> 
> I would imagine there would definitely be a way to display 
> both straight lines on the one graph, but what about the 
> 2nd probelm I have?
> 
> Many Thanks,
> 
> Gary.
> 

-- 

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info

0
andy9699 (3616)
2/28/2004 2:16:50 PM
Reply:

Similar Artilces:

Problems printing in Publisher 2003 with HP PSC 2410 #2
I am new to publisher 2003 and am having great difficulties printing anything properly using an HP PSC 2410 all in one. As an example when trying to print a half page side folded pre-designed greetings card all that prints is page 1 and part of page 4, minus any text. Pages 2 and 3 are missing altogether. The print preview however displays everything correctly. I have reinstalled Office 2003 and updated the printer drivers to the latest versions but the problem remains. Any help is much appreciated. ...

Upgrading from Money 2002 #2
I have the original money 2002 that came with the computer and have never upgraded. Which is the best version to go to? More importantly, when I purchase and download the upgrade, will it go over the current program and update all the information that I currently have? Thanks and Happy New Year -- mfletcher The latest version in the US is Money+ aka Money 2008. Other geographies have different versions. Money keeps all your data in the .mny file not the program. When you install the new version it usually remembers where your .mny file was, makes a copy of it (for safety) and then up...

pantone colors #2
Is there a way to make Publisher 2007 show all Pantone Colors? I want 021 U. Find doesn't do it. B I don't think Publisher has all the Pantone colors. There are close equivalents. Not the same of course... C=0 M=53 Y=100 K=0 R=252 G=115 B=35 -- Mary Sauer http://msauer.mvps.org/ "Bob Wright" <mmpdallas@sbcglobal.net> wrote in message news:%23N1wilmHJHA.1364@TK2MSFTNGP04.phx.gbl... > Is there a way to make Publisher 2007 show all Pantone Colors? I want 021 U. > Find doesn't do it. > B Guess you are right, not all there. Weird. Close equivalents ...

How do I display two excel pages at the same time?
I want to have two excel pages displayed on my computer at the same time, but when I open both pages it uses the same master excel and when I toggle between the two it won't open both of them up. I'm using office 2003. Thanks for the help. -- snowtime ------------------------------------------------------------------------ snowtime's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=25982 View this thread: http://www.excelforum.com/showthread.php?threadid=393499 Open both and then do windows>arrange and vertical (or any of the other choices, I usuall...

Formulas don't work in certain cells #2
nope, the cells are formatted as numbers. I simply cannot figure thi out. -Jorda -- kalik24 ----------------------------------------------------------------------- kalik247's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1594 View this thread: http://www.excelforum.com/showthread.php?threadid=27423 Being formatted as numbers doesn't automatically mean they are numbers. Copy an empty cell formatted to General. Select your range of numbers and Paste Special>Add>OK>Esc Gord Dibben Excel MVP On Mon, 1 Nov 2004 11:59:46 -0600, kalik247 <kalik2...

Print Macro #2
Trying to write a macro to print a spreadsheet where the number of rows of data varies. What's wrong with this code? Dim rng As Range Set rng = Range("A1").End(xlDown).End(xlToRight) With ActiveSheet.PageSetup .PrintArea = rng End With Thank you. Pam Hi Pam Leave your PrintArea empty Excel will print all cells with a value on the sheet -- Regards Ron de Bruin (Win XP Pro SP-1 XL2002 SP-2) www.rondebruin.nl "Pam" <gasp0225@juno.com> wrote in message news:16e401c38521$a7d25420$3501280a@phx.gbl... > Trying to write a macro to ...

Importing data into Outlook #2
Is there a process or program with which I can transfer my ACT! data into Outlook contacts? Thanks! ...

Unable to send a message, its been trying for 24hrs #2
I have been tring to send an email that contains a photo, for the past 24hrs. it wont send. all I am able to see is "cannot open this file, Outlook has already begun transmission. It wont even let me delete the message http://www.howto-outlook.com/faq/messagestuckinoutbox.htm=20 --=81 Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. All unsolicited mail sent to my personal account will be deleted without reading. =20 After furious head scratching, tillybird asked: | I have been tring to send an email that contains a photo, for the | past ...

Time Zone / Incorrect Dates Displayed to User
When a user in the Central Time zone closes an opportunity and someone in the Mountain Time zone views it, the Actual Close Date is 1 day before the date the person in the Central Time zone selected. For instance... If someone in the Central Time zone closes an opportunity and selects the Actual Close Date as 6/2/2007: -- Users in the Central Time zone see: 6/2/2007 -- But users in the Mountain Time zone see: 6/1/2007 This is a big issue when running monthly reports as it makes some opportunities show in the wrong month... and will put that revenue in the wrong month. It would make mo...

Microsoft CRM 1.2 database export failed 01-27-06
I am receiving this message when I try to upgrade my CRM 1.2 to CRM 3.0, does any one have any idea what this means? ...

Cannot get my CImageList to display images?
Ok i am successfully diplaying images in my tree controls but not my list controls. I am using the following but not image is being displayed??? int nIndex = mListCtrl.InsertItem(LVIF_IMAGE | LVIF_TEXT,0,"hello", 0,0,7,0L); Where 7 is a valid index into my image list! Please help? That really doesn't help much. Since you got the tree control working I'm assuming that you are calling the list control's SetImageIist. Also for debugging purposes call GetImageCount on your image list to see how many images it loaded. Let me also point out that you can call this ...

owa logout show the page cannot be display
The event 36 was triggered when Outlook Web Access (2003) users clicked the "Log Off" shortcut. The OWA user would receive the following message when logging off: "The page cannot be displayed. I try to search on google, some of newsgroup report follow microsoft article Q318239 can fix the issue. but this article can not found on support.microsoft.com. anyone have experience about event 36 OWA logout issue. Please help ...

Sheet display vrs. Print Preview
Why would a sheet display differently than when it is printed. I have an excel file that looks like it prints on my bosses computer but on my pc the page breaks are different the word warps are different. This makes it difficult to work with because it will not print the same on my pc and his. We are both using Excel 2003. Thanks for helping. This could have a great deal to do with the printer drivers. Are you printing to the same printer? ******************* ~Anne Troy www.OfficeArticles.com www.MyExpertsOnline.com "Byron" <Byron@discussions.microsoft.com> wrote in mes...

Refresh Display
Hi, From a MRMS COM add-in, how could I force a display refresh or only a transaction item refresh? I'm changing the PurchasedQuantity from a COM Add-in, the change only shows after I do a manual intervention on the POS current transaction. Jerome qsBridge.FireEvent ("RefreshDisplay") Description Refresh the POS Display. This is used when an item has been directly added to the current QSRules transaction. Parameters None Return Value True if the command was suc...

Ad Hoc Reporting #2
Hi, I am putting together an ad hoc report in Excel. My query is in the VB editor. I am trying to specify criteria Select x,y,z where... in the WHERE, I am struggling. I want to take a range of ids specified in the worksheet, F2:F55. So Select x, y, z where IDs IN ( F2:F55 ) I tried to use WHERE IN ( Range(F2:F55) ) but it did not like it. What syntax should I use to make this work? Thanks! ...

Reinstall #2
I am reinstalling Office 2003 on a new computer. I have installed the software but I the contact information and calendars, messages, notes etc have not transferred to the new one. How can I do that? ...

GetTextExtentPoint32 #2
Hi, I have multiple problems here :( I have a short text in UNICODE and the text contains newlines as well (carriage return and newline) and it seems that GetTextExtentPoint32 doesn't take into account the newlines. So I broke the lines myself and checked which has the longest length. Also, for the "int cbString" parameter, if my text is "hello" and I pass 5, then it doesn't return the current width. I have to send 6. Yes, I do select my font in the HDC before calling this. Other problem! Interline spacing issue Lines are separated by a certain mount of pixels...

Incoming Emails #2
Do I always have to click the "Send/Receive" button in order to get my new emails? No, you can go to TOOLS, then SEND/RECEIVE SETTINGS and then DEFINE SEND/RECEIVE SETTINGS and in the box's shown, you can tell Outlook to automatically send or receive your messages every XX mins. Tedd -- Tedd Riggs PDASquare Content Developer www.pdasquire.com "wj" <anonymous@discussions.microsoft.com> wrote in message news:88174331-72B4-4ECF-B688-DF745D9178EF@microsoft.com... > Do I always have to click the "Send/Receive" button in order to get my new emails? T...

is there a way of using a second monitor as a customer display
This is a multi-part message in MIME format. ------=_NextPart_000_018F_01C86B1D.3EAD2F60 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hello, Does anyone know if rms works with 2 monitors. What I mean can you use a second monitor as customer display or something similar. A lot of pos systems out there use a second monitor as customer display, I m not sure if rms supports that option or not but any help would be appreciated. thanks ------=_NextPart_000_018F_01C86B1D.3EAD2F60 Content-Type: text/html; charset="us-ascii" Content-Transfer-...

vba to prevent display of default series in doughnut chart
I am generating a doughnut chart using VBA and am having two immediat issues: 1) I am using the following line to ensure that the default chart tha is generated when I invoke the Charts.Add method is a doughnut chart: Application.SetDefaultChart FormatName:=xlDoughnut Is there a more elegant approach to ensuring that any chart create ends up being a doughnut chart, maybe when invoking the Charts.Ad method? I have tried to specify ChartType = xlDoughnut after th Charts.Add method but this does not do the trick every time (see cod snippet below). 2) When the doughnut chart is added (immediat...

How do I show a data table with legend keys in a line chart?
I am having trouble inserting a data table with legend keys into a line chart that contains a horizontal target line. Can anyone help me? Hi, I tried it in both 2007 and 2003 and had no problems. We need more infomation, can you post a sample of the chart somewhere. The only issue I have is that the target line is displayed on the data table, which I would prefer that it not be. -- Thanks, Shane Devenshire "excelbanker" wrote: > I am having trouble inserting a data table with legend keys into a line chart > that contains a horizontal target line. Can anyone he...

outlook client problem #2
Hi I have a one user that have problem with outlook client are always prompt to login outlook 2007 crmclient V3C and have all patch install You might want to create a new profile for that client. Also check that they are running SQL 2005 Express on their desktop as opposed to an MSDE instance. Their was a shift in databases from 2000 to 2005 during the life of CRM v3.0 "sjm" wrote: > Hi > I have a one user that have problem with outlook client are always prompt to > login > outlook 2007 > crmclient V3C and have all patch install Hi sjm, Is the user also prom...

CTreeView #2
I use TVS_SHOWSELALWAYS style with the tree control. When the focus from the view is lost, the selection bar turns pale grey. Is there a way I could change the color of selection bar? Thanks in advance You may be able to use OnCustomDraw() to do this sort of thing. http://www.pocketpcdn.com/articles/tree_color.html http://cvs.sourceforge.net/viewcvs.py/shareaza/shareaza/CtrlSharedFolder.cpp?rev=1.3 http://www.codeguru.com/Cpp/controls/treeview/newlistviewcontrolie40/article.php/c711/ Tom "RG" <nobody@nowhere.com> wrote in message news:eZSucQKrFHA.3264@TK2MSFTNGP12...

Attachment security in Outlook 2003 #2
I had the same problem. I downloaded DetachOL form the link below and it fixed all my problems. You can choose different levels of security. Hope this helps http://www.mcdev.com/outlook.shtml ...

Unable to display the folder. The inbox folder could not be found
I'm new to Exchange. I'm setting up a very small exchange system at home (MSDN), in order to learn a little about it before making the decision to move to it in the office or not. My home server is acting as both a PDC and Exchange Server. All appears to be fine, and I can access my exchange account, while my other half can access her exchange account. However, although I've given myself access to my other-half's inbox (sharing, given my user "Publishing Editor" access to her inbox), when I attempt to open her inbox from Outlook, I receive the message "Unable...