?
Solved

Changing Row Color in MSChart Controls?!

Posted on 2004-04-04
5
Medium Priority
?
2,483 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
Simple Linear Regression
Starting up a Project

777 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