Jump to content
Software FX Community

Conditional Formating


User (Legacy)

Recommended Posts

You can do this using axis sections.

You first need to determine where the Sat and Sun are in your data and

create the sections accordingly.

Something like this:

int n = chart1.NValues;

int nSection = 0;

for (int i = 0; i < n; i++) {

double x = chart1.XValue[0,i];

DateTime dt = DateTime.FromOADate(x);

if (dt.DayOfWeek == DayOfWeek.Saturday) {

AxisSection section = chart1.AxisX.Sections[nSection];

section.From = i + 1;

section.To = i + 2.5;

section.BackColor = Color.Aquamarine;

nSection++;

i++; // Skip next Sunday

}

}

}

--

FP

Software FX

Link to comment
Share on other sites

That worked great!  Thank you.

Now... Is possible to put point value labels on only those points that

extend beyond the max value of the YAxis?

Thanks.

... Will

"SoftwareFX Support" <noreply@softwarefx.com> wrote in message

news:p9DyDwOHEHA.2848@webserver3.softwarefx.com...

> You can do this using axis sections.

>

> You first need to determine where the Sat and Sun are in your data and

> create the sections accordingly.

>

> Something like this:

>

>

> int n = chart1.NValues;

>

> int nSection = 0;

>

> for (int i = 0; i < n; i++) {

>

> double x = chart1.XValue[0,i];

>

> DateTime dt = DateTime.FromOADate(x);

>

> if (dt.DayOfWeek == DayOfWeek.Saturday) {

>

> AxisSection section = chart1.AxisX.Sections[nSection];

>

> section.From = i + 1;

>

> section.To = i + 2.5;

>

> section.BackColor = Color.Aquamarine;

>

> nSection++;

>

> i++; // Skip next Sunday

>

> }

>

> }

>

>

> }

>

>

> --

> FP

> Software FX

>

>

>

Link to comment
Share on other sites

Yes.

Conditional attributes is what you are looking for.

As you may already know Chart FX 6.2 allows you to assign attributes such as

color, point label, etc. to specific points of the chart. Conditional

attributes goes a step beyond and allows you to automatically assign these

attributes based on predefined conditions. For example you can do:

ConditionalAttributes conditional = chart1.ConditionalAttributes[0];

conditional.PointLabels = true;

conditional.Condition.From = <max value>

conditonal.Condition.To = double.PositiveInfinity;

Note: Please check the code for syntax accuracy, at not at my desk at this

moment.

--

FP

Software FX, Inc.

Link to comment
Share on other sites

Well... mixed results with that one.

I get the label on some points that go above the limit, but not all. Its

kind of random too. Here's what I'm using in VB:

Dim condition As ConditionalAttributes

Condition = ctObj.ConditionalAttributes(0)

Condition.PointLabels = True

Condition.Condition.From = 12.5

Condition.Condition.To = Double.PositiveInfinity

I've tried applying this before and after databind(), but no change.

... Will

"Software FX Support" <support@softwarefx.com> wrote in message

news:7FqtXQqHEHA.2848@webserver3.softwarefx.com...

> Yes.

>

> Conditional attributes is what you are looking for.

>

> As you may already know Chart FX 6.2 allows you to assign attributes such

as

> color, point label, etc. to specific points of the chart. Conditional

> attributes goes a step beyond and allows you to automatically assign these

> attributes based on predefined conditions. For example you can do:

>

> ConditionalAttributes conditional = chart1.ConditionalAttributes[0];

> conditional.PointLabels = true;

> conditional.Condition.From = <max value>

> conditonal.Condition.To = double.PositiveInfinity;

>

> Note: Please check the code for syntax accuracy, at not at my desk at this

> moment.

>

> --

> FP

> Software FX, Inc.

>

>

Link to comment
Share on other sites

This code works perfectly for me. All points greater or equal than 12.5get

labeled.

This needs to be doe PRIOR to setting the data.

If you are having problems please provide a sample that reproduces it. As I

said patting this code into a brand new project and setting random data to

the chart I get the appropriate results.

--

FP

Software FX

Link to comment
Share on other sites

Here are two charts created with the exact same code, just slightly

different data. The conditions were set PRIOR to the databind().

Also notice that the XAxis label for the rightmost column is missing. Any

thoughts there?

... Will

"SoftwareFX Support" <noreply@softwarefx.com> wrote in message

news:vOjJmaJIEHA.788@webserver3.softwarefx.com...

> This code works perfectly for me. All points greater or equal than 12.5get

> labeled.

>

> This needs to be doe PRIOR to setting the data.

>

> If you are having problems please provide a sample that reproduces it. As

I

> said patting this code into a brand new project and setting random data to

> the chart I get the appropriate results.

>

> --

> FP

> Software FX

>

>

Link to comment
Share on other sites

Clipped bar will NEVER display the point label. That is bars which value is

greater than the Max. This is by design.

This seems to be the case here. Since you didn't post the data I can not be

sure but I suspect this is the problem.

You need to increase the Max value in your Y-Axis so that these bars are not

clipped if you wan to see their point label.

--

FP

Software FX

Attachments.zip

Attachments.zip

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...