intreeg
asked on
How to control the color of each slice in a pie chart using ASP and OWC?
I cannot find any descent documentation on formatting pie charts using ASP and OWC. How can I set the color of each slice of the pie chart to the value of my choice?
ASKER
I have read over that one a few times, if the answer is there I am not observant enough to find it... I am thinking that maybe I am not collecting/setting the data properly.
Do you know if I need to create a series for each pie slice? I belive that is the only way becuase as you posted :
objChart.SeriesCollection( 2).Interio r.Color = "red"
The code is modifing the interior color for the entire series. So I guess if that is the only way to control the color, I will need to figure out how to get my data into a seperate series for each slice. Can anyone tell me if this is the direction I need to go or am I missing somehting?
Do you know if I need to create a series for each pie slice? I belive that is the only way becuase as you posted :
objChart.SeriesCollection(
The code is modifing the interior color for the entire series. So I guess if that is the only way to control the color, I will need to figure out how to get my data into a seperate series for each slice. Can anyone tell me if this is the direction I need to go or am I missing somehting?
ASKER
Here is the portion of my code that is supposed to generate the graph. However all I get now is a blank gif
...
set objChartSpace = Server.CreateObject("OWC.C hart")
set objChart = objChartSpace.Charts.Add()
set c = objChartSpace.Constants
objChart.Type = c.chChartTypePie
objChart.HasLegend = True
ColorTable.Open "select * from Chart_Color WHERE DeckName = '"&Request.Form("deckname" ) &"' order by Color"
set objChartSpace.DataSource = ColorTable
objChart.SetData c.chDimSeriesNames, 0, "Color"
for each objSeries in objChart.SeriesCollection
Response.Write "test<br>"
objSeries.SetData c.chDimCategories, 0, "Color"
objSeries.SetData c.chDimValues, 0, "Cards"
next
for each axis in objChart.Axes
axis.HasTitle = True
if axis.Type = c.chCategoryAxis then
axis.Title.Caption = "Color"
else
axis.Title.Caption = "Cards"
end if
next
...
The table looks like this:
RowId | Color | Cards | DeckName
1 | Blue | 10 | My Deck
2 | Red | 5 | My Deck
etc.
it appears that in this statemnet:
for each objSeries in objChart.SeriesCollection
that there are no objSeriers in the SeriesCollection.... any ideas on why that is?
...
set objChartSpace = Server.CreateObject("OWC.C
set objChart = objChartSpace.Charts.Add()
set c = objChartSpace.Constants
objChart.Type = c.chChartTypePie
objChart.HasLegend = True
ColorTable.Open "select * from Chart_Color WHERE DeckName = '"&Request.Form("deckname"
set objChartSpace.DataSource = ColorTable
objChart.SetData c.chDimSeriesNames, 0, "Color"
for each objSeries in objChart.SeriesCollection
Response.Write "test<br>"
objSeries.SetData c.chDimCategories, 0, "Color"
objSeries.SetData c.chDimValues, 0, "Cards"
next
for each axis in objChart.Axes
axis.HasTitle = True
if axis.Type = c.chCategoryAxis then
axis.Title.Caption = "Color"
else
axis.Title.Caption = "Cards"
end if
next
...
The table looks like this:
RowId | Color | Cards | DeckName
1 | Blue | 10 | My Deck
2 | Red | 5 | My Deck
etc.
it appears that in this statemnet:
for each objSeries in objChart.SeriesCollection
that there are no objSeriers in the SeriesCollection.... any ideas on why that is?
You can use the following to set the color property for your chart
objChartSpace.Charts(0).In terior.Col or
AS to why are you not getting the chart I don't know but you can view this sample code, it might help:::
Set objChartSpace = New OWC11.ChartSpace
Set chConstants = objChartSpace.Constants
objChartSpace.Charts.Add
If (CStr(Charttype) = "PIE") Then
chttype = objChartSpace.Constants.ch ChartTypeP ie
End If
If (CStr(Charttype) = "LINE") Then
chttype = objChartSpace.Constants.ch ChartTypeL ineMarkers
End If
TitleChart(0) = "Effort Distribution Activitywise For " & Day(varStartDate) & "/" & MonthName(Month(varStartDa te), True) & "/" & Year(varStartDate) & " --" & Day(varFinishDate) & "/" & MonthName(Month(varFinishD ate), True) & "/" & Year(varFinishDate)
objChartSpace.Charts(0).Ty pe = chttype
objChartSpace.Charts(0).Ha sLegend = (objChartSpace.Charts(0).T ype = objChartSpace.Constants.ch ChartTypeL ineMarkers )
i = 0
While Not rsSmgBl.EOF
For j = 0 To rsSmgBl.Fields.Count - 2
Categories(i + j) = rsSmgBl(j).Name
Values(i + j) = rsSmgBl(j)
Next
rsSmgBl.MoveNext
i = i + 1
Wend
objChartSpace.Charts(0).Se riesCollec tion.Add
objChartSpace.Charts(0).Se riesCollec tion(0).Ca ption = TitleChart(0)
objChartSpace.Charts(0).Se riesCollec tion(0).Se tData chConstants.chDimCategorie s, chConstants.chDataLiteral, Categories
objChartSpace.Charts(0).Se riesCollec tion(0).Se tData chConstants.chDimValues, chConstants.chDataLiteral, Values
Set SeriesLabels = objChartSpace.Charts(0).Se riesCollec tion(0).Da taLabelsCo llection.A dd
' Set the number format of the data labels.
SeriesLabels.NumberFormat = "0.00"
objChartSpace.Charts(0).In terior.Bac kColor
' Set the data labels to display the value
' for the data point.
SeriesLabels.HasValue = True
objChartSpace.Charts(0).Ha sTitle = True
' Set the chart title.
objChartSpace.Charts(0).Ti tle.Font = "Tahoma"
objChartSpace.Charts(0).Ti tle.Font.S ize = 8
objChartSpace.Charts(0).Ti tle.Font.B old = True
'ChartSpace1.Charts(0).Tit le.Caption = asSeriesNames(0)
'Set a variable to the Category (X) axis.
Set axCategoryAxis = objChartSpace.Charts(0).Ax es(0)
' Set a variable to the Value (Y) axis.
Set axValueAxis = objChartSpace.Charts(0).Ax es(1)
rsSmgBl.MoveFirst
' The following two lines of code enable, and then
' set the title for the category axis.
axCategoryAxis.HasTitle = True
axCategoryAxis.Title.Capti on = "Project Activities (" & rsSmgBl("prj_Name") & ")"
' The following three lines of code set the font
' for the values displayed on the category axis.
axCategoryAxis.Font = "Arial"
axCategoryAxis.Font.Size = 8
axCategoryAxis.Font.Bold = True
' The following two lines of code enable, and then
' set the title for the value axis.
axValueAxis.HasTitle = True
axValueAxis.Title.Caption = "Efforts (Hrs)" 'Put your Cation for Y-Axis
' The following three lines of code set the font
' for the values displayed on the value axis.
axValueAxis.Font = "Arial"
axValueAxis.Font.Size = 8
axValueAxis.Font.Bold = True
' Export the chart to the temporary file
objChartSpace.ExportPictur e l_path, "gif", 800, 400
faheem
objChartSpace.Charts(0).In
AS to why are you not getting the chart I don't know but you can view this sample code, it might help:::
Set objChartSpace = New OWC11.ChartSpace
Set chConstants = objChartSpace.Constants
objChartSpace.Charts.Add
If (CStr(Charttype) = "PIE") Then
chttype = objChartSpace.Constants.ch
End If
If (CStr(Charttype) = "LINE") Then
chttype = objChartSpace.Constants.ch
End If
TitleChart(0) = "Effort Distribution Activitywise For " & Day(varStartDate) & "/" & MonthName(Month(varStartDa
objChartSpace.Charts(0).Ty
objChartSpace.Charts(0).Ha
i = 0
While Not rsSmgBl.EOF
For j = 0 To rsSmgBl.Fields.Count - 2
Categories(i + j) = rsSmgBl(j).Name
Values(i + j) = rsSmgBl(j)
Next
rsSmgBl.MoveNext
i = i + 1
Wend
objChartSpace.Charts(0).Se
objChartSpace.Charts(0).Se
objChartSpace.Charts(0).Se
objChartSpace.Charts(0).Se
Set SeriesLabels = objChartSpace.Charts(0).Se
' Set the number format of the data labels.
SeriesLabels.NumberFormat = "0.00"
objChartSpace.Charts(0).In
' Set the data labels to display the value
' for the data point.
SeriesLabels.HasValue = True
objChartSpace.Charts(0).Ha
' Set the chart title.
objChartSpace.Charts(0).Ti
objChartSpace.Charts(0).Ti
objChartSpace.Charts(0).Ti
'ChartSpace1.Charts(0).Tit
'Set a variable to the Category (X) axis.
Set axCategoryAxis = objChartSpace.Charts(0).Ax
' Set a variable to the Value (Y) axis.
Set axValueAxis = objChartSpace.Charts(0).Ax
rsSmgBl.MoveFirst
' The following two lines of code enable, and then
' set the title for the category axis.
axCategoryAxis.HasTitle = True
axCategoryAxis.Title.Capti
' The following three lines of code set the font
' for the values displayed on the category axis.
axCategoryAxis.Font = "Arial"
axCategoryAxis.Font.Size = 8
axCategoryAxis.Font.Bold = True
' The following two lines of code enable, and then
' set the title for the value axis.
axValueAxis.HasTitle = True
axValueAxis.Title.Caption = "Efforts (Hrs)" 'Put your Cation for Y-Axis
' The following three lines of code set the font
' for the values displayed on the value axis.
axValueAxis.Font = "Arial"
axValueAxis.Font.Size = 8
axValueAxis.Font.Bold = True
' Export the chart to the temporary file
objChartSpace.ExportPictur
faheem
This would be a better example::
This will help you get the graph i.e gif file.
As far as changing the color of chart is concerned, wait for my next post.
<%@ language="vbscript" %>
<%
Dim oChart, c, Categories(5), Val1(25),Val2(25), i, sCaption, nData, nOrg
set cn=server.createobject("ad odb.connec tion")
set rs=server.createobject("ad odb.record set")
cn.open("Provider=Microsof t." & _
"Jet.OLEDB.4.0;Data Source=C:\smgcode" & _
"\dbSmg.mdb;" & _
"Persist Security Info=False")
rs.Open "Select ec_PlannedCoding as coding,ec_PlannedAnalysis from tbEffortCapture",cn
i=0
while not rs.EOF
Categories(i) = "Week"& CStr(i+1)
Response.Write rs(0) & "<BR>" & rs(1)
Val1(i) = rs(0)
Val2(i) = rs(1)
rs.MoveNext
i=i+1
wend
' Create a Chart Object
Set oChart = CreateObject("OWC10.ChartS pace")
Set c = oChart.Constants
' Set the different parameters for the ChartSpace
oChart.Border.Color = c.chColorNone
' Get Organization number and use it to set the Caption
sCaption1 = "Planned Coding"
sCaption2 = "Planned Analysis"
' Add a chart and set parameters for the chart
' 6 = to line chart
' 12 = smooth line curve
oChart.Charts.Add
oChart.Charts(0).Type = 6
oChart.Charts(0).SeriesCol lection.Ad d
oChart.Charts(0).SeriesCol lection(0) .Caption = sCaption1
oChart.Charts(0).SeriesCol lection(0) .SetData c.chDimCategories, c.chDataLiteral, Categories
oChart.Charts(0).SeriesCol lection(0) .SetData c.chDimValues, c.chDataLiteral, Val1
'oChart.Charts.Add
'oChart.Charts(0).Type = 6
oChart.Charts(0).SeriesCol lection.Ad d
oChart.Charts(0).SeriesCol lection(1) .Caption = sCaption2
oChart.Charts(0).SeriesCol lection(1) .SetData c.chDimCategories, c.chDataLiteral, Categories
oChart.Charts(0).SeriesCol lection(1) .SetData c.chDimValues, c.chDataLiteral, Val2
oChart.Charts(0).HasLegend = True
oChart.Charts(0).HasTitle = True
' Get a temporary filename to save chart in that file
sFname = Session("FSO").GetTempName & session.SessionID & ".gif"
' Export the chart to the temporary file
oChart.ExportPicture server.MapPath(sFname), "gif", 600, 512
' Create a link to the generated file
Response.Write "<img src='" & sFname & "'>"
' Store the file with its path in the session object for cleanup
Session("sTempFile" & Session("n")) = Server.MapPath(sFname)
' Increment the number of files
Session("n") = Session("n") + 1
%>
This will help you get the graph i.e gif file.
As far as changing the color of chart is concerned, wait for my next post.
<%@ language="vbscript" %>
<%
Dim oChart, c, Categories(5), Val1(25),Val2(25), i, sCaption, nData, nOrg
set cn=server.createobject("ad
set rs=server.createobject("ad
cn.open("Provider=Microsof
"Jet.OLEDB.4.0;Data Source=C:\smgcode" & _
"\dbSmg.mdb;" & _
"Persist Security Info=False")
rs.Open "Select ec_PlannedCoding as coding,ec_PlannedAnalysis from tbEffortCapture",cn
i=0
while not rs.EOF
Categories(i) = "Week"& CStr(i+1)
Response.Write rs(0) & "<BR>" & rs(1)
Val1(i) = rs(0)
Val2(i) = rs(1)
rs.MoveNext
i=i+1
wend
' Create a Chart Object
Set oChart = CreateObject("OWC10.ChartS
Set c = oChart.Constants
' Set the different parameters for the ChartSpace
oChart.Border.Color = c.chColorNone
' Get Organization number and use it to set the Caption
sCaption1 = "Planned Coding"
sCaption2 = "Planned Analysis"
' Add a chart and set parameters for the chart
' 6 = to line chart
' 12 = smooth line curve
oChart.Charts.Add
oChart.Charts(0).Type = 6
oChart.Charts(0).SeriesCol
oChart.Charts(0).SeriesCol
oChart.Charts(0).SeriesCol
oChart.Charts(0).SeriesCol
'oChart.Charts.Add
'oChart.Charts(0).Type = 6
oChart.Charts(0).SeriesCol
oChart.Charts(0).SeriesCol
oChart.Charts(0).SeriesCol
oChart.Charts(0).SeriesCol
oChart.Charts(0).HasLegend
oChart.Charts(0).HasTitle = True
' Get a temporary filename to save chart in that file
sFname = Session("FSO").GetTempName
' Export the chart to the temporary file
oChart.ExportPicture server.MapPath(sFname), "gif", 600, 512
' Create a link to the generated file
Response.Write "<img src='" & sFname & "'>"
' Store the file with its path in the session object for cleanup
Session("sTempFile" & Session("n")) = Server.MapPath(sFname)
' Increment the number of files
Session("n") = Session("n") + 1
%>
You can change color as follows::This example will help you.
Set chConstants = ChartSpace1.Constants
Set serSeries1 = ChartSpace1.Charts(0).Seri esCollecti on(0)
Set serSeries2 = ChartSpace1.Charts(0).Seri esCollecti on(1)
' Set the interior fill of the first series to a two-color gradient.
serSeries1.Interior.SetTwo ColorGradi ent chConstants.chGradientDiag onalDown, _
chConstants.chGradientVari antCenter, "Blue", "Silver"
' Set the interior fill of the second series to a solid color.
serSeries2.Interior.SetSol id "Purple"
' Set the interior fill of the plot area to a preset texture.
ChartSpace1.Charts(0).Plot Area.Inter ior.SetTex tured _
chConstants.chTextureParch ment, chConstants.chTile
Set chConstants = ChartSpace1.Constants
Set serSeries1 = ChartSpace1.Charts(0).Seri
Set serSeries2 = ChartSpace1.Charts(0).Seri
' Set the interior fill of the first series to a two-color gradient.
serSeries1.Interior.SetTwo
chConstants.chGradientVari
' Set the interior fill of the second series to a solid color.
serSeries2.Interior.SetSol
' Set the interior fill of the plot area to a preset texture.
ChartSpace1.Charts(0).Plot
chConstants.chTextureParch
ASKER
I dont have time to work with this today, but I plan on trying it out tomorrow. Let me ask you this though, I need my pie chart to have 8 slices, so will i need to have 8, SeriesCollection's?
And if so I will need to change my 8 arrays to hold the values?
Like :
val1 = 1,0,0,0,0,0,0,0
val2 = 0,1,0,0,0,0,0,0
And one array for the categories (or slices)
cats = Black,Blue,Red,Green,White ,Land,Mult iColor,Art ifact
If you can answer those questions I think I will have it figured out.
TIA!
Intreeg
And if so I will need to change my 8 arrays to hold the values?
Like :
val1 = 1,0,0,0,0,0,0,0
val2 = 0,1,0,0,0,0,0,0
And one array for the categories (or slices)
cats = Black,Blue,Red,Green,White
If you can answer those questions I think I will have it figured out.
TIA!
Intreeg
ASKER
Or even better can I use a two-dimensional array for the values?
val(0,0) = 1
val(0,0) = 0
etc..
val(1,0) = 0
val(1,1) = 1
etc...
val(0,0) = 1
val(0,0) = 0
etc..
val(1,0) = 0
val(1,1) = 1
etc...
ASKER
I got a chance to through this together real quick, I get a blank chart here are links to the gifs I have created with this:
Pie -> http://discus.gatheringground.com/pie.gif
Line -> http://discus.gatheringground.com/line.gif
Here is the code (minus DB connection stuff):
Function conCardColor(id, tblName)
ccSQL = "SELECT reff_entry FROM reff_entry WHERE "&_
"reffentry_id = " & id
'&" AND table_name = '" & tblName &"'"
Set oConColor = oConn.Execute(ccSQL)
conCardColor = oConColor("reff_entry")
End Function
dim categories(8)
dim BlackVals(8)
dim BlueVals(8)
dim GreenVals(8)
dim WhiteVals(8)
dim RedVals(8)
dim ArtifactVals(8)
dim LandVals(8)
dim MultiVals(8)
'Set all values to 0
For i=0 to Ubound(categories)-1
BlackVals(i)= 0
BlueVals(i)= 0
GreenVals(i)= 0
WhiteVals(i)= 0
RedVals(i)= 0
ArtifactVals(i)= 0
LandVals(i)= 0
MultiVals(i)= 0
Next
set oColors = Server.CreateObject("ADODB .RecordSet ")
oColors.Open "SELECT * FROM reff_entry WHERE reff_id = 9",oConn,2,3
i=0
Do While NOT oColors.EOF
categories(i) = oColors("reff_entry")
i=i+1
oColors.MoveNext
Loop
oColors.Close
numCards = Request("numCards")
CardsSQL = "SELECT num2c FROM item WHERE "
For i=0 to numCards-1
CardsSQL = CardsSQL & "product_id = " & Request.Form("product"&i) &" "
If i <> numCards-1 Then
CardsSQL = CardsSQL & "OR "
Else
CardsSQL = CardsSQL & ";"
End If
Next
objRst.Open CardsSQL
Do While Not objRst.EOF
Select Case conCardColor(objRst("num2c "),"Color" )
Case "Black"
BlackVals(0) = BlackVals(0) + 1
Case "Blue"
BlueVals(1) = BlueVals(1) + 1
Case "Green"
GreenVals(2) = GreenVals(2) + 1
Case "White"
WhiteVals(3) = WhiteVals(3) + 1
Case "Red"
RedVals(4) = RedVals(4) + 1
Case "Artifact"
ArtifactVals(5) = ArtifactVals(5) + 1
Case "Land"
LandVals(6) = LandVals(6) + 1
Case "Multicolor"
MultiVals(7) = MultiVals(7) + 1
Case Else
End Select
objRst.MoveNext
Loop
' Create a Chart Object
Set oChart = CreateObject("OWC10.ChartS pace")
Set c = oChart.Constants
' Set the different parameters for the ChartSpace
oChart.Border.Color = c.chColorNone
oChart.Charts.Add
oChart.Charts(0).Type = c.chChartTypePie
oChart.Charts(0).HasLegend = True
oChart.Charts(0).HasTitle = False
For i=0 to Ubound(categories)-1
oChart.Charts(0).SeriesCol lection.Ad d
oChart.Charts(0).SeriesCol lection(i) .Caption = sCaption1
oChart.Charts(0).SeriesCol lection(i) .SetData c.chDimCategories, c.chDataLiteral, Categories
Select Case categories(i)
Case "Black"
oChart.Charts(0).SeriesCol lection(i) .SetData c.chDimValues, c.chDataLiteral, BlackVals
oChart.Charts(0).SeriesCol lection(i) .Interior. SetSolid categories(i)
Case "Blue"
oChart.Charts(0).SeriesCol lection(i) .SetData c.chDimValues, c.chDataLiteral, BlueVals
oChart.Charts(0).SeriesCol lection(i) .Interior. SetSolid categories(i)
Case "Green"
oChart.Charts(0).SeriesCol lection(i) .SetData c.chDimValues, c.chDataLiteral, GreenVals
oChart.Charts(0).SeriesCol lection(i) .Interior. SetSolid categories(i)
Case "White"
oChart.Charts(0).SeriesCol lection(i) .SetData c.chDimValues, c.chDataLiteral, WhiteVals
oChart.Charts(0).SeriesCol lection(i) .Interior. SetSolid categories(i)
Case "Red"
oChart.Charts(0).SeriesCol lection(i) .SetData c.chDimValues, c.chDataLiteral, RedVals
oChart.Charts(0).SeriesCol lection(i) .Interior. SetSolid categories(i)
Case "Artifact"
oChart.Charts(0).SeriesCol lection(i) .SetData c.chDimValues, c.chDataLiteral, ArtifactVals
oChart.Charts(0).SeriesCol lection(i) .Interior. SetSolid "Gray"
Case "Land"
oChart.Charts(0).SeriesCol lection(i) .SetData c.chDimValues, c.chDataLiteral, LandVals
oChart.Charts(0).SeriesCol lection(i) .Interior. SetSolid "Brown"
Case "Multicolor"
oChart.Charts(0).SeriesCol lection(i) .SetData c.chDimValues, c.chDataLiteral, MultiVals
oChart.Charts(0).SeriesCol lection(i) .Interior. SetSolid "Yellow"
Case Else
End Select
Next
deckName = Replace(Replace(Replace(Re quest("dec kName")," ",""),"!",""),"?","")
strFileName = "temp-" & deckName & "-ColorChart-" & Second(Now())& ".gif"
sFullFileName = Server.MapPath(".") & "\temp\" & strFileName
response.write sFullFileName
oChart.ExportPicture sFullFileName, "gif", 250, 200
%>
Pie -> http://discus.gatheringground.com/pie.gif
Line -> http://discus.gatheringground.com/line.gif
Here is the code (minus DB connection stuff):
Function conCardColor(id, tblName)
ccSQL = "SELECT reff_entry FROM reff_entry WHERE "&_
"reffentry_id = " & id
'&" AND table_name = '" & tblName &"'"
Set oConColor = oConn.Execute(ccSQL)
conCardColor = oConColor("reff_entry")
End Function
dim categories(8)
dim BlackVals(8)
dim BlueVals(8)
dim GreenVals(8)
dim WhiteVals(8)
dim RedVals(8)
dim ArtifactVals(8)
dim LandVals(8)
dim MultiVals(8)
'Set all values to 0
For i=0 to Ubound(categories)-1
BlackVals(i)= 0
BlueVals(i)= 0
GreenVals(i)= 0
WhiteVals(i)= 0
RedVals(i)= 0
ArtifactVals(i)= 0
LandVals(i)= 0
MultiVals(i)= 0
Next
set oColors = Server.CreateObject("ADODB
oColors.Open "SELECT * FROM reff_entry WHERE reff_id = 9",oConn,2,3
i=0
Do While NOT oColors.EOF
categories(i) = oColors("reff_entry")
i=i+1
oColors.MoveNext
Loop
oColors.Close
numCards = Request("numCards")
CardsSQL = "SELECT num2c FROM item WHERE "
For i=0 to numCards-1
CardsSQL = CardsSQL & "product_id = " & Request.Form("product"&i) &" "
If i <> numCards-1 Then
CardsSQL = CardsSQL & "OR "
Else
CardsSQL = CardsSQL & ";"
End If
Next
objRst.Open CardsSQL
Do While Not objRst.EOF
Select Case conCardColor(objRst("num2c
Case "Black"
BlackVals(0) = BlackVals(0) + 1
Case "Blue"
BlueVals(1) = BlueVals(1) + 1
Case "Green"
GreenVals(2) = GreenVals(2) + 1
Case "White"
WhiteVals(3) = WhiteVals(3) + 1
Case "Red"
RedVals(4) = RedVals(4) + 1
Case "Artifact"
ArtifactVals(5) = ArtifactVals(5) + 1
Case "Land"
LandVals(6) = LandVals(6) + 1
Case "Multicolor"
MultiVals(7) = MultiVals(7) + 1
Case Else
End Select
objRst.MoveNext
Loop
' Create a Chart Object
Set oChart = CreateObject("OWC10.ChartS
Set c = oChart.Constants
' Set the different parameters for the ChartSpace
oChart.Border.Color = c.chColorNone
oChart.Charts.Add
oChart.Charts(0).Type = c.chChartTypePie
oChart.Charts(0).HasLegend
oChart.Charts(0).HasTitle = False
For i=0 to Ubound(categories)-1
oChart.Charts(0).SeriesCol
oChart.Charts(0).SeriesCol
oChart.Charts(0).SeriesCol
Select Case categories(i)
Case "Black"
oChart.Charts(0).SeriesCol
oChart.Charts(0).SeriesCol
Case "Blue"
oChart.Charts(0).SeriesCol
oChart.Charts(0).SeriesCol
Case "Green"
oChart.Charts(0).SeriesCol
oChart.Charts(0).SeriesCol
Case "White"
oChart.Charts(0).SeriesCol
oChart.Charts(0).SeriesCol
Case "Red"
oChart.Charts(0).SeriesCol
oChart.Charts(0).SeriesCol
Case "Artifact"
oChart.Charts(0).SeriesCol
oChart.Charts(0).SeriesCol
Case "Land"
oChart.Charts(0).SeriesCol
oChart.Charts(0).SeriesCol
Case "Multicolor"
oChart.Charts(0).SeriesCol
oChart.Charts(0).SeriesCol
Case Else
End Select
Next
deckName = Replace(Replace(Replace(Re
strFileName = "temp-" & deckName & "-ColorChart-" & Second(Now())& ".gif"
sFullFileName = Server.MapPath(".") & "\temp\" & strFileName
response.write sFullFileName
oChart.ExportPicture sFullFileName, "gif", 250, 200
%>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have worked on this problem for sometime now, even read a book on OWC and there appears to be no well-documented or even possible solution to this problem. I will most likely use a component of some type. As for now, I am using OWC and have no control over what color is assigned to what slice.
ASKER
I will close this question and award points to faheem, as his suggestions came very close to solving the problem, as close as you can get I believe. If anyone figures out the solution please feel free to email me : websupport@gatheringground .com
I know that I could'nt help you. Even then you rewarded my efforts.
That was very generous of you. Thankyou very much.
I look forward to help you out in any of your future problems.
-Faheem
That was very generous of you. Thankyou very much.
I look forward to help you out in any of your future problems.
-Faheem
ASKER
No problem, I appreciate the effort very much! If I ever get it figured out I will post the final solution here.
From what I understand, you cannot have more than one series collection for a pie chart. It does not allow for multiple 'pie charts' which is what multiple series would imply. That is why you get a blank gif image. I know this is an old post but in case someone else is wondering why that doesn't work there is your explanation.
I have been trying to change the colors and thus far I'm unable to find a solution. The closest I've come is to omit any color specifications and use the default color scheme (at least the pie sections are different colors, although they are ugly).
I have been trying to change the colors and thus far I'm unable to find a solution. The closest I've come is to omit any color specifications and use the default color scheme (at least the pie sections are different colors, although they are ugly).
I have finally solved this problem. The solution is found in part of the series collection name space (under charts). You must set the color for each Point in that series collection to whatever color you want. Below is the example.
'Set your chart up assigning the chart type, data, etc.
'Step through a loop setting each color for each data point in the seriescollection
For X as integer = 0 to chart(0).seriescollection( 0).length - 1
chart(0).seriescollection( 0).points( X).interio r.setsolid ('Whatever color you want')
Next
This will set each piece to whatever color you assign. I usually just have an array of colors and inside the setsolid call I place colors(X) where colors is the name of my color array.
I hope this helps other people out there. After hours of searching and trying different things I finally stumbled across the solution that worked for me.
'Set your chart up assigning the chart type, data, etc.
'Step through a loop setting each color for each data point in the seriescollection
For X as integer = 0 to chart(0).seriescollection(
chart(0).seriescollection(
Next
This will set each piece to whatever color you assign. I usually just have an array of colors and inside the setsolid call I place colors(X) where colors is the name of my color array.
I hope this helps other people out there. After hours of searching and trying different things I finally stumbled across the solution that worked for me.
objChart.SeriesCollection(
objChart.SeriesCollection(