Solved

Changing Row Color in MSChart Controls?!

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article will show, step by step, how to integrate R code into a R Sweave document
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

932 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

10 Experts available now in Live!

Get 1:1 Help Now