Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Changing Row Color in MSChart Controls?!

Posted on 2004-04-04
5
Medium Priority
?
2,493 Views
Last Modified: 2012-06-21
hey, the title says it all.

I can change the "series" colour, which is technically the column, but is there any way of changing an individual row colour? i.e. 5 columns, 2 rows... and all 10 bars different colours??

thanks very much,

Adam Miles
0
Comment
Question by:ajmilesno1
  • 2
5 Comments
 
LVL 11

Expert Comment

by:lbertacco
ID: 10755228
Yes, the following example assumes you have one chart inside your worksheet (not a separate sheet) and set color 3 (red) to the third point of every serires.

Public Sub ChangeRowCol()
    Dim s As Series
    For Each s In ChartObjects(1).Chart.SeriesCollection
        s.Points(3).Interior.ColorIndex = 3
    Next s
End Sub

0
 

Author Comment

by:ajmilesno1
ID: 10757185
ermm i have to admit to not knowing how to implement your answer.

I am using vb and have a chart called "timechart", and it was 1 column, 5 rows. I want each of the five rows to be different colours. However the properties of a such a chart only allow you to change the colour of each series/column, and all bars within that series/column appear to have to be the same colour.

If this is what your code does then great, but I'm not quite sure how it works.

thanks,

Adam
0
 
LVL 11

Accepted Solution

by:
lbertacco earned 400 total points
ID: 10757533
Sorry, for some reason (when I answered I was woring in Excel) I thought you where talking about VBA and Excel charts.

Anyway, if I do this in VB (v6)
Dim a(0, 20)
For i = 0 To 20
    a(0, i) = Rnd
Next i
MSChart1.ChartData = a

That is, if you have only 1 series with n values, then you can just change to n series with 1 value each. Of course this might be unacceptable for you (e.g. if you want a legend)
If you have multiple series, from documentation at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/mschrt/html/vbcoldatapointscollection.asp 
you see that you cannot currently access properties of single points (and maybe you should switch to better -third party- chart controls)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question