Jump to content
Software FX Community

Setting color on zero-value point sets same color on all zero-value points


habuma
 Share

Recommended Posts

If I have a bar/gantt chart and I decide to highlight one of the points using the following:

 

chart.Points[seriesIndex, pointIndex].Color = Color.Green;

And if the point happens to be a zero value, then the color of all other zero-valued points in the chart (in all series) are also set to green.  Similarly, I can set the BarShape for a zero-valued point and all zero-valued points will have their BarShape changed.

What gives? (FWIW, I'm using the latest  2664 build of ChartFX for Visual Studio 2005)

Link to comment
Share on other sites

Yes...I am using ConditionalAttributes. But I'm only using them to adjust the point label when the points are zero...I don't do anything with the color.

Good catch...I think I understand that because they're zero values, the ConditionalAttributes gets applied to all of the points...so they all have the same attributes and when I set one's color I set them all. Got that...sorta...

But then another question comes up: If I don't specify the series (chart.Points[pointIndex]), then I can set the color for only one of the points, implying that I get a different attributes object for each point...Why? Of course, while this will work with a 1-series chart, it isn't so great for an n-series chart. 

Is there a way that I can use a ConditionalAttributes to adjust point labels for zero-value items, but also individually set the point colors? 

Link to comment
Share on other sites

Further investigation turns up the following:

  • On the zero-valued points, referencing chart.Points[seriesIndex, pointIndex] always gives me the same object, presumably the ConditionalAttributes object that I setup that should be applied to zero-valued points. Not desirable, but not surprising, I suppose.
  • On those same zero-valued points, referencing chart.Points[pointIndex] gives me a different object for each point. This is the desired behavior, but surprises me in light of what I found in the first bullet.
  • Whether it's the same attributes object for all points or not, I'd expect the results from chart.Points[pointIndex] and chart.Points[seriesIndex.pointIndex] to be consistent with each other for all points in the same series.

Again, after considering the use of ConditionalAttributes, I suppose that I should expect the same attributes object given to me for all points when using chart.Points[seriesIndex, pointIndex]. But I really need a way to individually control the colors of a specific point, even when conditional attribute is in effect for the point. Is there any way to pull that off?

 

Link to comment
Share on other sites

Conditional attributes and per-point attributes can not be mixed as they rely on the same underlying engine.

You will need to eliminate the conditional attributes and assign the attributes for each point independently. Doing:

 chart.Poin[i,j].Color = <color>;

for example, will create a new set of attribute for point (i,j) if one was not there already, this will allow you to set different attributes for different points.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...