# Vary Colors By Point

S

I am accessing excel through .NET C#..

I have two data series in a chart(XYScatterLines)..And I want to vary color
by point
of one series ...Infact I am not able to do that directly in excel manually...

I even Tried following code..

grp = (ChartGroup)newChartObject.Chart.ChartGroups(1);
grp.VaryByCategories = true;

B

#### Barb Reinhardt

If you want to vary the colors by some known parameters, I've done it by
creating a series for each of the colors and only displaying the ponits that
are Yellow in one series, green in another. If I want the points connected,
I still plot the original series with connectors.

S

Hi Barb
Yeah I could make every line in the graph as a series and assign the color
index...It's a cool idea..

This serves my purpose...But I really think one should have a option of vary
by points for a series on a chart when there are more than one series on the
chart...

Anyways Thanx very much...

P

#### Peter T

You say your chart contains two series, but VaryByCategories can only be
applied to the ONE AND ONLY series on the chart. You could apply your own
colour to each point. Here's a VBA example

Sub VBPseries1()
Dim i As Long
Dim cht As Chart
Dim sr As Series
Dim pt As Point
Set cht = ActiveChart ' the selected chart
Set sr = cht.SeriesCollection(1)
i = 24
For Each pt In sr.Points
i = i + 1
If i Mod 57 = 0 Then i = 1
With pt
'.Border.ColorIndex = i ' only if Line
.MarkerForegroundColorIndex = i
.MarkerBackgroundColorIndex = i
End With
Next

End Sub

Regards,
Peter T

J

#### Jon Peltier

Did you ever notice which colors are used for the separate points? They are
the same colors are used for separate series, so point 2 of series 1 would
use the default color of series 2.

But don't worry, I've thought of a way to get the effect you want. Create
your chart with two series. Move one of the series to the secondary axis.
You can delete the secondary axes and the secondary axis plot will still be
associated with the secondary axes but will plot along the primary axes.
Now, if you only have one series per axis group either or both can utilize
the Vary Colors By Point option.

- Jon

P

#### Peter T

That's pretty cool!

point can only be applied to the sole series on the chart was wrong, rather
than a sole series per chart group.

Regards,
Peter T

J

#### Jon Peltier

Yeah, but I'm not into rubbing people's noses in it. Well, not people I
like.

Any way, I'd have said the same thing, but for some reason a little voice
encouraged me to try something.

- Jon

P

#### Peter T

Peter T

Jon Peltier said:
Yeah, but I'm not into rubbing people's noses in it. Well, not people I
like.

Any way, I'd have said the same thing, but for some reason a little voice
encouraged me to try something.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______
<snip>