A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Charts and Charting
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

How To Modify One Point In A Graph...



 
 
Thread Tools Display Modes
  #1  
Old November 25th, 2004, 09:09 AM
Pierre
external usenet poster
 
Posts: n/a
Default How To Modify One Point In A Graph...


Hi all,
I have a problem I cannot solve.. I think it is an EXCEL BUG !!
Could somebody have a quick lok at my spreadsheet.. it should take only
few minutes... otherwise, here is the details of my concern....

I have 2 series (Credit and Volatility) on the same graph.

Date Credit Volatility B/S Flag
25/03/04 30 42 B
25/04/04 35 45 S
25/05/04 34 43
25/06/04 38 42 S


I want to change the shape of specific points : put a big green square
when there is a "B" flag, or put a Big red square when there is a "S"
flag (see the spreadhsset enclosed)

Everything is fine for the second serie but the first one generate
completely random markerstyle and color instead of a red or green
square !
I am calling the same function for both (see in the VBA code) !!

PLEASE..... HELP !!!!!!
Is it a bug or am I becoming mad ???????


Here is the VBA code... long but easy to read...

Public Sub GenerateGraph()

'extract the number of elements for the graph
nbData = wsGraph.Range("GRAPH_NB_DATA")

'Generate the X, Y1 and Y2 strings to generate the graph
X_String = "=Graphics!R3C4:R" & nbData + 2 & "C4"
Y1_String = "=Graphics!R3C5:R" & nbData + 2 & "C5"
Y2_String = "=Graphics!R3C6:R" & nbData + 2 & "C6"

'Now, create the graph with the string generated above
Application.ScreenUpdating = False
ActiveSheet.ChartObjects("Chart 10").Activate
ActiveChart.PlotArea.Select
ActiveChart.SeriesCollection(1).XValues = X_String
ActiveChart.SeriesCollection(1).Values = Y1_String
ActiveChart.SeriesCollection(2).XValues = X_String
ActiveChart.SeriesCollection(2).Values = Y2_String

'At this point, set the first serie with a uniform and clean
'line (with a triangle for each point and color 32=Blue)
'(Macro below...)
SetGraphPoint 1, 32, xlTriangle

'At this point, set the first serie with a uniform and clean
'line (with a square for each point and color 7=magenta)
SetGraphPoint 2, 7, xlSquare

'And now the BUG !!!
'change the pattern if there is a B in the column G
'and put a green big square
'or put a red big square if there is a S
For i = 1 To nbData
If wsGraph.Cells(2 + i, 7) = "B" Then
'Do the "green conversion" for the first serie '
'(Macro below...)
SetGraphPoint_BUY 1, i
'Do the "green conversion" for the second serie
SetGraphPoint_BUY 2, i

ElseIf wsGraph.Cells(2 + i, 7) = "S" Then
'Do the "red conversion" for the first serie
'(Macro below...)
SetGraphPoint_SELL 1, i
'Do the "red conversion" for the second serie
SetGraphPoint_SELL 2, i
End If
Next i

'OK, it is finished !!
wsGraph.Range("A1").Select
Application.ScreenUpdating = True

End Sub

'Here we set the irGraph-th graphic to be with the irColor color and
with the irMarkerStyle Marker
' in order to have a clean and uniform graph
Private Sub SetGraphPoint(irGraph, irColor, irMarkerStyle)
ActiveChart.SeriesCollection(irGraph).Select
With Selection
.Border.ColorIndex = irColor
.Border.Weight = xlMedium
.Border.LineStyle = xlContinuous
.MarkerBackgroundColorIndex = irColor
.MarkerForegroundColorIndex = irColor
.MarkerStyle = irMarkerStyle
.Smooth = True
.MarkerSize = 6
.Shadow = False
End With
End Sub

'Here I modify the irPoint-ht point in the irGraph-th graph with a big
green square marker with a black cross
Private Sub SetGraphPoint_BUY(irGraph, IrPoint)
ActiveChart.SeriesCollection(irGraph).Points(IrPoi nt).Select
With Selection
.MarkerBackgroundColorIndex = 4
.MarkerForegroundColorIndex = 1
.MarkerStyle = xlX
.MarkerSize = 8
.Shadow = False
End With
End Sub


'Here I modify the irPoint-ht point in the irGraph-th graph with a big
red square marker with a black star
Private Sub SetGraphPoint_SELL(irGraph, IrPoint)
ActiveChart.SeriesCollection(irGraph).Points(IrPoi nt).Select
With Selection
.MarkerBackgroundColorIndex = 3
.MarkerForegroundColorIndex = 1
.MarkerStyle = xlStar
.MarkerSize = 8
.Shadow = False
End With
End Sub


+-------------------------------------------------------------------+
|Filename: TEST.zip |
|Download: http://www.excelforum.com/attachment.php?postid=2809 |
+-------------------------------------------------------------------+

--
Pierre
------------------------------------------------------------------------
Pierre's Profile: http://www.excelforum.com/member.php...fo&userid=3754
View this thread: http://www.excelforum.com/showthread...hreadid=320351

  #2  
Old November 25th, 2004, 09:52 AM
Andy Pope
external usenet poster
 
Posts: n/a
Default

Hi Pierre,

Your chart had me fooled for a moment. I though you had indeed found a
bug. But no, select the Credit data series and on the Options tab of the
Format dialog uncheck the 'Vary Colours by Points'.
Your code should work as expected.

Cheers
Andy

Pierre wrote:
Hi all,
I have a problem I cannot solve.. I think it is an EXCEL BUG !!
Could somebody have a quick lok at my spreadsheet.. it should take only
few minutes... otherwise, here is the details of my concern....

I have 2 series (Credit and Volatility) on the same graph.

Date Credit Volatility B/S Flag
25/03/04 30 42 B
25/04/04 35 45 S
25/05/04 34 43
25/06/04 38 42 S


I want to change the shape of specific points : put a big green square
when there is a "B" flag, or put a Big red square when there is a "S"
flag (see the spreadhsset enclosed)

Everything is fine for the second serie but the first one generate
completely random markerstyle and color instead of a red or green
square !
I am calling the same function for both (see in the VBA code) !!

PLEASE..... HELP !!!!!!
Is it a bug or am I becoming mad ???????


Here is the VBA code... long but easy to read...

Public Sub GenerateGraph()

'extract the number of elements for the graph
nbData = wsGraph.Range("GRAPH_NB_DATA")

'Generate the X, Y1 and Y2 strings to generate the graph
X_String = "=Graphics!R3C4:R" & nbData + 2 & "C4"
Y1_String = "=Graphics!R3C5:R" & nbData + 2 & "C5"
Y2_String = "=Graphics!R3C6:R" & nbData + 2 & "C6"

'Now, create the graph with the string generated above
Application.ScreenUpdating = False
ActiveSheet.ChartObjects("Chart 10").Activate
ActiveChart.PlotArea.Select
ActiveChart.SeriesCollection(1).XValues = X_String
ActiveChart.SeriesCollection(1).Values = Y1_String
ActiveChart.SeriesCollection(2).XValues = X_String
ActiveChart.SeriesCollection(2).Values = Y2_String

'At this point, set the first serie with a uniform and clean
'line (with a triangle for each point and color 32=Blue)
'(Macro below...)
SetGraphPoint 1, 32, xlTriangle

'At this point, set the first serie with a uniform and clean
'line (with a square for each point and color 7=magenta)
SetGraphPoint 2, 7, xlSquare

'And now the BUG !!!
'change the pattern if there is a B in the column G
'and put a green big square
'or put a red big square if there is a S
For i = 1 To nbData
If wsGraph.Cells(2 + i, 7) = "B" Then
'Do the "green conversion" for the first serie '
'(Macro below...)
SetGraphPoint_BUY 1, i
'Do the "green conversion" for the second serie
SetGraphPoint_BUY 2, i

ElseIf wsGraph.Cells(2 + i, 7) = "S" Then
'Do the "red conversion" for the first serie
'(Macro below...)
SetGraphPoint_SELL 1, i
'Do the "red conversion" for the second serie
SetGraphPoint_SELL 2, i
End If
Next i

'OK, it is finished !!
wsGraph.Range("A1").Select
Application.ScreenUpdating = True

End Sub

'Here we set the irGraph-th graphic to be with the irColor color and
with the irMarkerStyle Marker
' in order to have a clean and uniform graph
Private Sub SetGraphPoint(irGraph, irColor, irMarkerStyle)
ActiveChart.SeriesCollection(irGraph).Select
With Selection
Border.ColorIndex = irColor
Border.Weight = xlMedium
Border.LineStyle = xlContinuous
MarkerBackgroundColorIndex = irColor
MarkerForegroundColorIndex = irColor
MarkerStyle = irMarkerStyle
Smooth = True
MarkerSize = 6
Shadow = False
End With
End Sub

'Here I modify the irPoint-ht point in the irGraph-th graph with a big
green square marker with a black cross
Private Sub SetGraphPoint_BUY(irGraph, IrPoint)
ActiveChart.SeriesCollection(irGraph).Points(IrPoi nt).Select
With Selection
MarkerBackgroundColorIndex = 4
MarkerForegroundColorIndex = 1
MarkerStyle = xlX
MarkerSize = 8
Shadow = False
End With
End Sub


'Here I modify the irPoint-ht point in the irGraph-th graph with a big
red square marker with a black star
Private Sub SetGraphPoint_SELL(irGraph, IrPoint)
ActiveChart.SeriesCollection(irGraph).Points(IrPoi nt).Select
With Selection
MarkerBackgroundColorIndex = 3
MarkerForegroundColorIndex = 1
MarkerStyle = xlStar
MarkerSize = 8
Shadow = False
End With
End Sub


+-------------------------------------------------------------------+
|Filename: TEST.zip |
|Download: http://www.excelforum.com/attachment.php?postid=2809 |
+-------------------------------------------------------------------+


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
  #3  
Old November 25th, 2004, 09:57 AM
Andy Pope
external usenet poster
 
Posts: n/a
Default

Hi Pierre,

Your chart had me fooled for a moment. I though you had indeed found a
bug. But no, select the Credit data series and on the Options tab of the
Format dialog uncheck the 'Vary Colours by Points'.
Your code should work as expected.

Cheers
Andy

Pierre wrote:
Hi all,
I have a problem I cannot solve.. I think it is an EXCEL BUG !!
Could somebody have a quick lok at my spreadsheet.. it should take only
few minutes... otherwise, here is the details of my concern....

I have 2 series (Credit and Volatility) on the same graph.

Date Credit Volatility B/S Flag
25/03/04 30 42 B
25/04/04 35 45 S
25/05/04 34 43
25/06/04 38 42 S


I want to change the shape of specific points : put a big green square
when there is a "B" flag, or put a Big red square when there is a "S"
flag (see the spreadhsset enclosed)

Everything is fine for the second serie but the first one generate
completely random markerstyle and color instead of a red or green
square !
I am calling the same function for both (see in the VBA code) !!

PLEASE..... HELP !!!!!!
Is it a bug or am I becoming mad ???????


Here is the VBA code... long but easy to read...

Public Sub GenerateGraph()

'extract the number of elements for the graph
nbData = wsGraph.Range("GRAPH_NB_DATA")

'Generate the X, Y1 and Y2 strings to generate the graph
X_String = "=Graphics!R3C4:R" & nbData + 2 & "C4"
Y1_String = "=Graphics!R3C5:R" & nbData + 2 & "C5"
Y2_String = "=Graphics!R3C6:R" & nbData + 2 & "C6"

'Now, create the graph with the string generated above
Application.ScreenUpdating = False
ActiveSheet.ChartObjects("Chart 10").Activate
ActiveChart.PlotArea.Select
ActiveChart.SeriesCollection(1).XValues = X_String
ActiveChart.SeriesCollection(1).Values = Y1_String
ActiveChart.SeriesCollection(2).XValues = X_String
ActiveChart.SeriesCollection(2).Values = Y2_String

'At this point, set the first serie with a uniform and clean
'line (with a triangle for each point and color 32=Blue)
'(Macro below...)
SetGraphPoint 1, 32, xlTriangle

'At this point, set the first serie with a uniform and clean
'line (with a square for each point and color 7=magenta)
SetGraphPoint 2, 7, xlSquare

'And now the BUG !!!
'change the pattern if there is a B in the column G
'and put a green big square
'or put a red big square if there is a S
For i = 1 To nbData
If wsGraph.Cells(2 + i, 7) = "B" Then
'Do the "green conversion" for the first serie '
'(Macro below...)
SetGraphPoint_BUY 1, i
'Do the "green conversion" for the second serie
SetGraphPoint_BUY 2, i

ElseIf wsGraph.Cells(2 + i, 7) = "S" Then
'Do the "red conversion" for the first serie
'(Macro below...)
SetGraphPoint_SELL 1, i
'Do the "red conversion" for the second serie
SetGraphPoint_SELL 2, i
End If
Next i

'OK, it is finished !!
wsGraph.Range("A1").Select
Application.ScreenUpdating = True

End Sub

'Here we set the irGraph-th graphic to be with the irColor color and
with the irMarkerStyle Marker
' in order to have a clean and uniform graph
Private Sub SetGraphPoint(irGraph, irColor, irMarkerStyle)
ActiveChart.SeriesCollection(irGraph).Select
With Selection
Border.ColorIndex = irColor
Border.Weight = xlMedium
Border.LineStyle = xlContinuous
MarkerBackgroundColorIndex = irColor
MarkerForegroundColorIndex = irColor
MarkerStyle = irMarkerStyle
Smooth = True
MarkerSize = 6
Shadow = False
End With
End Sub

'Here I modify the irPoint-ht point in the irGraph-th graph with a big
green square marker with a black cross
Private Sub SetGraphPoint_BUY(irGraph, IrPoint)
ActiveChart.SeriesCollection(irGraph).Points(IrPoi nt).Select
With Selection
MarkerBackgroundColorIndex = 4
MarkerForegroundColorIndex = 1
MarkerStyle = xlX
MarkerSize = 8
Shadow = False
End With
End Sub


'Here I modify the irPoint-ht point in the irGraph-th graph with a big
red square marker with a black star
Private Sub SetGraphPoint_SELL(irGraph, IrPoint)
ActiveChart.SeriesCollection(irGraph).Points(IrPoi nt).Select
With Selection
MarkerBackgroundColorIndex = 3
MarkerForegroundColorIndex = 1
MarkerStyle = xlStar
MarkerSize = 8
Shadow = False
End With
End Sub


+-------------------------------------------------------------------+
|Filename: TEST.zip |
|Download: http://www.excelforum.com/attachment.php?postid=2809 |
+-------------------------------------------------------------------+


--

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

  #4  
Old November 25th, 2004, 10:08 AM
Pierre
external usenet poster
 
Posts: n/a
Default


Many thanks Andy, this stuff was getting me crazy !!!


--
Pierre
------------------------------------------------------------------------
Pierre's Profile: http://www.excelforum.com/member.php...fo&userid=3754
View this thread: http://www.excelforum.com/showthread...hreadid=320351

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Graph and Charts Kart18 General Discussion 0 October 19th, 2004 04:39 PM
Pivot graph Ludavhen Worksheet Functions 3 August 25th, 2004 12:20 AM
Excdel graph Pat Worksheet Functions 0 August 21st, 2004 07:14 PM
Maximum point of graph Jerry W. Lewis Charts and Charting 3 May 6th, 2004 03:15 AM
mark a particular point on a graph Mark Kennedy Charts and Charting 1 May 1st, 2004 01:01 AM


All times are GMT +1. The time now is 05:22 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.