This is a migrated thread and some comments may be shown as answers.

PointMarkItemStyle when data is sampled

4 Answers 93 Views
Chart
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Kornelije
Top achievements
Rank 1
Kornelije asked on 26 Apr 2012, 02:06 PM

Hi!

I've noticed that the PointMarkItemStyle's binding is ignored when the data is sampled, which is in a way expected.

I have a series with data values that have two states: real and estimate, defined by the Model's IsEstimated value.

I've set the PointMarkItemStyle to:

<Style  x:Key="InterpolatedPointMarkStyle"
        TargetType="telerik:PointMark">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="telerik:PointMark">
                <Canvas>
                    <Path x:Name="PART_PointMarkPath"
                          Canvas.Left="{Binding DataItem.PointMarkMargin}"
                          Canvas.Top="{Binding DataItem.PointMarkMargin}"
                          Style="{TemplateBinding ShapeStyle}"
                          Width="{Binding DataItem.PointMarkSize}"
                          Height="{Binding DataItem.PointMarkSize}"
                          Opacity="{Binding DataItem.PointMarkOpacity}"
                          Stretch="Fill">
                        <Path.Data>
                            <PathGeometry x:Name="PART_PointMarkPathGeometry" />
                        </Path.Data>
                    </Path>
                </Canvas>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

Note that I'm using the PointMarkSize, PointMarkMargin, PointMarkOpacity to define the visual representation of the data.

If the value is estimated (IsEstimated == true), the point is somewhat smaller and its opacity is set to 0.7.

However, the chart was completely ignoring my binding (showing no points at all), as seen on the first image (style ignored.png).

Then I realized that I have about 140 points, and the Chart's Sampling was set to 50 points. Upon setting the Sampling to 200 (or any number of points larger than my number of points), the chart's sampling automatically turned off and PointMarkItemStyle was applied. (Style Applied.png).

I am aware that when sampling takes place, several points may be grouped into one, making it impossible to trivially determine whether the new point satisfies the conditions the individual points did. But is there any way to make data points (in sampled series) still apply the style, where a data point would be set to Estimated if ANY of the underlying points in the group are Estimated?

If not, what would be the way to find out whether a specific series is currently sampled?

4 Answers, 1 is accepted

Sort by
0
Accepted
Petar Marchev
Telerik team
answered on 01 May 2012, 09:09 AM
Hello Kornelije,
 
Thank you for the attached images and explanations.

I have looked into this issue and actually it is not the sampling feature that is responsible for the template not being applied. In fact the template is being applied - it is just not visible.

What happens, when sampling is applied, is that a DataItem is not being passed to the DataPoint. The DataPoint is the DataContext of the PointTemplate, so all of these bindings DataItem.SomeProperty fail, because the DataItem is null. I can see that you are applying sizes and margins - and these are actually not working, but the template is applied.

I hope that I explained it well enough!

1. One work around I can suggest is to do the sampling yourself - before you pass the actual items source - sample the data items into some mediator-data-points and pass this new collection to the source of the chart. This way you will surely have control of what is going on.       

2. Another suggestion I can make is to fully disable sampling (by setting the threshold to zero).

I hope this helps! 

Kind regards,
Petar Marchev
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Kornelije
Top achievements
Rank 1
answered on 03 May 2012, 06:58 AM

The second solution is not an option as we have too many points so the sampling is needed.

The first solution is obvious. The reasoning was - why implement something that's already existing (in Telerik controls).

It is obvious that the DataItem is empty, since the new DataPoint is created by aggregating multiple original points.

I believe a great addition to the RadChart control would be a property of IEnumerable<Object> that would contain all the DataItems from which the sampled DataPoint was created (by aggregation). With that option and the help of a ValueConverter I believe we would be able to modify the template to customize the appearance of a DataPoint (even when sampled).

Thanks for the reply.

0
Petar Marchev
Telerik team
answered on 07 May 2012, 09:00 AM
Hello Kornelije,

I understand that it can be helpful to have the items which determine the data point, but we do not have intentions of adding such a functionality to the RadChart. We are planning on this for the new RadChartView. We are sorry for the inconvenience. 

Greetings,
Petar Marchev
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Kornelije
Top achievements
Rank 1
answered on 13 Jun 2012, 01:17 PM

A part of what I wanted was solved by using FallbackValue in Binding.

Height="{Binding DataItem.PointMarkSize, FallbackValue=6}"

And to repeat that for all the properties bound to DataItem.

Therefore, when data is sampled, FallbackValue will be used.

I hope this can help someone.

Tags
Chart
Asked by
Kornelije
Top achievements
Rank 1
Answers by
Petar Marchev
Telerik team
Kornelije
Top achievements
Rank 1
Share this question
or