Hi,
I would like to know how to use the Strip line in the XamDataChart. I would like to add different colour bands on the chart according to the data in the chart? Can anyone please advise me on this function?
Thanks,
Pieter
Pieter, you can set a brush on the Strip property on both axes. You should pick a color with some transparency (change the alpha value) and you will see a neat effect on the strip crossing. But are you talking about putting the strip at a configurable set of values? We don't directly support this, but I may be able to help you out with a sample. Could you explain in more detail what you are trying to do?
-Graham
Hi Graham,
Thanks again for replying.
I am adding an image this is just an example of what I should do. There is a trace on the graph if it drops below 0 it should make the background red, if it stays on a point for longer than 10 minutes the background must be orange and the last one if it goes above 20 it must change the background to green. My problem is I don’t know how to do this checks in XAML and I don’t know what function to call in C#?
I will appreciate any advice on this. The XAML code is the same as my other post on the X Axis.
Thank You!
Thank you for all the work you did here!
I want to test it now but I don’t know what references you are using, I can’t find the reference that will let me use the <local:ChartStripsBehavior>,
I did download the latest service release (2010.2) and it’s installed.
How do I add the local:ChartStripsBehavior to the Xaml page
Thank You,
Pieter,
ChartStripsBehavior is defined in the code behind section of the post. So when you copy in that code, it will be defined in your local assembly. You need to define a namespace prefix to access types in your local assembly from xaml, so up after the other namspace prefix decralations add this:
xmlns:local="clr-namespace:X"
where X is the namespace were you put ChartStripsBehavior. If that is in a seperate assembly than the one where you are writing this xaml page, then you will need something like this instead:
xmlns:local="clr-namespace:X;assembly=Y"
where X is the namespace that contains ChartStripsBehavior and Y is the assembly that contains ChartStripsBehavior.
see here for more info: http://msdn.microsoft.com/en-us/library/ms747086.aspx
That help?
Hi Graham
Thanks it helped a lot!
It’s almost working now; I am just having a problem with the ClearExisting function. It’s giving me a compile error on the ‘xAxis.RootCanvas.Children’ Description is – ‘Could not find an implementation of the query pattern for source type system.Windows.Controls.UIElementCollection'. 'Where' not found. Consider explicitly specifying the type of the range variable 'child'.’ Any idea how to fix this?
Thank you!
Make sure you have "using System.Linq;" with your other using statements at the top of the file. Let me know if that resolves the problem.
I do have the System.Linq in. I did some googeling but I can’t get an answer.
This is everything I have in.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Infragistics.Controls.Charts;
using Infragistics.Collections;
using System.Data.Linq;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
Aha. I was using a CategoryXAxis when I should have been using a CategoryDateTimeXAxis with the DateTime MemberPath set.
My strips are not drawing. Do you have any idea why the GetScaledValue function would return numbers like 1.1378021398827587E+18 for a date of 11/1/2011 1:00:00 AM (634557060000000000 Ticks), a window {0,0,1,1}, and a viewport {0,0,467.99,277.04}? That's the end date. The start date is 7/20/2011 1:00:00 AM (634467204000000000 Ticks) scales to 1.137641022222069E+18. I don't think this function is behaving correctly. Do you happen to have a scaling function that works correctly?
An approach like above presented needs to be more complicated in order to deal with that kind of volume. Is there a sample that you can provide that replicates your scenario? I may be able to point out how you can adjust this extension in order to perform well with that level of annotation. But, as a warning, the code is likely to be more complicated.
Performance is absolutely horrendeous on these strips. I have a chart with 2000 points and 200 annotations like this.
For anyone else interested, Graham's solution relies on XamDataChart events firing to refresh strips which you may need to address when the chart is set as the XamZoombar preview content.
Additionally the GetScaledValue calls rely on x axis ActualMinimumValue and ActualMaximumValue having meaningful values, which in my situation was not the case. This is easily overcome by implementing your own scaling method.