Hi
Our team is currently working on the DataChart and one requirement is about the labels in the axis.
We need to set the tick origin(where the first tick mark is at) and interval according to the user input, but i found no property to set the tick origin.
So i turns to use the TickMarkValues to meet the requirements.
Unfortunately, the only example i found is about the CustomTickMarkValues and there is no way to dynamically bind the values.
Anybody has suggestions? thanks a lot.
Hello Ding,
Thank you for posting to Infragistics Community!
I have been looking into your question and created a small sample with a XamDataChart including a NumericYAxis. To start with, I believe you are referring to the Creating Custom Axis Tickmark Values approach as demonstrated in the documentation topic here, is this correct? In case you would like to dynamically bind the first/last/interval values for the tick marks, a possible approach is to directly bind the MinimumValue, MaximumValue and Interval properties of the NumericYAxis object to corresponding properties of your view model.
<ig:NumericYAxis x:Name="yAxis" Title="Y-Axis" MinimumValue="{Binding Path=TickOrigin}" MaximumValue="{Binding Path=Last}" Interval="{Binding Path=Interval}">
The sample demonstrates this solution by allowing you to modify those values via three text boxes and directly observe the tick marks being updated. Please, test it on your side and if you require any further assistance on the matter, please let me know.
Sincerely,Bozhidara PachilovaAssociate Software Developer
8535.XDCDynamicTickMarkValues.zip
Hi Bozhidara,
Thanks for your quick response.
For the first question, Yes. I tried to bind the the expected TickMarkValues to the CustomTickMarkValues but didn't work.
For your approach, it is not what we exactly want because we still want the have the min/max binding to other values.
A picture is easier to show.
If i set TickOrigin to 4 and interval to 2 while min is 0 and max is 12.
This is what we expect.
Is this reachable?
Hi Ding,
Thank you for following up.
I understand that the suggested approach does not meet your requirement completely as the TickOrigin and Last values might differ from the MinimumValue and MaximumValue. The Custom Axis Tickmark Values approach is the way to go about this, however you are right that the example given in the documentation demonstrates statically defined values.
In an effort to adopt this approach to allow dynamically specifying the tick origin and interval values, I further modified the sample, so that an instance of the CustomTickmarkValues class is added as a member of the View Model and this instance is bound to the NumercYAxis TickmarkValues property:
TickmarkValues="{Binding CustomTickMarkVals, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
public CustomTickmarkValues(double tickOrigin, double interval, double last) { // define custom tickmark values this.Tickmarks = new DoubleCollection(); int tickCnt = (int)((last - tickOrigin) / interval) + 1; for (int i = 0; i < tickCnt; i++) { this.Tickmarks.Add(tickOrigin + i * interval); } }
The CustomTickmarkValues class constructor is modified to include the tick origin, interval and last (maximum value) as parameters, which are used to calculate the tick mark values. In case the min and max value are required to also be marked, their values can be added to the Tickmarks collection in the Initialize method:
this.Tickmarks.Add(this.First); this.Tickmarks.Add(this.Last);
Additionally, the bound CustomTickmarkValues object from the view model is reinitialized whenever the tick origin, interval or last values get changed, so that the change gets reflected.
Please, check out the modified sample and let me know if it helps achieve your requirement.
Best regards,Bozhidara PachilovaInfragistics
6116.XDCDynamicTickMarkValues-Modified.rar
Perfect, your solution fully meets the requirements.
Thanks a lot for your help.
I am glad that you find my suggestion helpful. Thank you for using Infragistics components.
Best regards,Bozhidara Pachilova