Solved

Changing Row Color in MSChart Controls?!

Posted on 2004-04-04
5
2,445 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 100 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

A short article about a problem I had getting the GPS LocationListener working.
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
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 …

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now