Solved

Changing Row Color in MSChart Controls?!

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

807 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