Avatar of williecg
williecgFlag for United States of America

asked on 

How to change chart point color based on other vallue in datasource

Hello Experts,
I have a net 4 chart in ms visual developer 2010.

It is a point chart.  The data source has Height, Weight, Date, Age.

I am plotting Height on x axis and weight on y axis.  The points are size 5 and blue in color.

Here is the question:

If the Age is >60 how can I turn the Blue point to Green?

Thanks,

Cgee
.NET ProgrammingVB Script

Avatar of undefined
Last Comment
williecg
Avatar of harfang
harfang
Flag of Switzerland image

Hello williecg,

I don't know about “net 4 charts”, but since you didn't get an answer, this is how I would do it in other charting tools.

Instead of changing the colours of points, create a new series for each group you want to represent. Each series can have a different marker and different marker colours. Although many charting tools allow to manipulate individual points, it's generally easier to work with entire series. But I can't help you with the details of the manipulations...

(°v°)
Avatar of PrisonBroken
PrisonBroken
Flag of United Kingdom of Great Britain and Northern Ireland image

Hi Cgee,

Not sure I understand all of what you are saying but assume you are grabbing the data from a database of some sort.

So something like this might work


Dim dataSource As SqlDataSource = New SqlDataSource(connectionString, selectSql)
Dim view6 As Data.DataView = dataSource.Select

            With Chart1.("Series1")
                For i = 0 To .Points.Count
                    If view6.Rows(i).columns(intColumnWithAgesIn).values >= 60 Then
                        .Points(i).Color = Color.Green
                    End If
                Next
            End With
Avatar of williecg
williecg
Flag of United States of America image

ASKER

harfang:

Thanks that is the "general case" solution. i did not think about it because I was actually thinking of the special case where I want to highlight only one data point in a series.

If I can't get some Net 4 action going here, I will implement your suggestion.  

I am not a pro and my frame of reference in charting in ms excel.

PrisonBroken:

It is a database with records containing the data elements I mentioned.

Actually, it is a database containing a whole bunch of other stuff.  I made up the example so the business problem details I am trying to solve do not get in the way of this learning opportunity.

If I get the answer to this question, I can extend it to my "real" problem.

Thanks Pros,

Cgee
Avatar of PrisonBroken
PrisonBroken
Flag of United Kingdom of Great Britain and Northern Ireland image

Ah I read net 4 as asp.net 4 charting object is that not the case as that what the "example" I gave relates to.

Cheers
Avatar of williecg
williecg
Flag of United States of America image

ASKER

PrisonBroken:

asp.net 4 charting object

yes

Cgee
ASKER CERTIFIED SOLUTION
Avatar of PrisonBroken
PrisonBroken
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of williecg
williecg
Flag of United States of America image

ASKER

Thats what I am talking about. I knew there had to be a way to operate on an individual data point, I just do not have the detail knowledge to put it together without a map.

Thanks for hanging in there.

Cgee
.NET Programming
.NET Programming

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

137K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo