Hello Telerik!
I create my custom label strategy. All labels draw at the top of the chart. I use 30% of plotAreaClip.Bottom to get max bottom pixel.
01.
private
IEnumerable<RadRect> GetSlots(RadRect pointMark, RadRect label, RadRect plotAreaClip,
int
labelIndex)
02.
{
03.
var bottomBorder = plotAreaClip.Bottom*0.3;
04.
var leftShift = 25;
05.
for
(var i = 0;; i++)
06.
{
07.
var top = label.Height * i + labelIndex;
08.
if
(top > bottomBorder || top < plotAreaClip.Y)
09.
{
10.
break
;
11.
}
12.
yield
return
new
RadRect(pointMark.Center.X + leftShift, top, label.Width, label.Height);
13.
}
14.
yield
return
label;
15.
}
I would like to draw all my labels above 0 depth value (look at the attachment). The area above 0 depth area has dynamic height depending on data.
My idea is to pass Min and Max depth values from View Model into the strategy and based on the values dynamically compute needed pixel.
I wanted to create Dependency Property but ChartSmartLabelsStrategyBase is not inherited from DependencyObject
01.
public
class
TwoLineSeriesLabelsStrategy : ChartSmartLabelsStrategyBase
02.
{
03.
public
double
VerticalMinValue {
get
;
set
; }
04.
05.
public
static
readonly
DependencyProperty VerticalMinValueProperty = DependencyProperty.RegisterAttached(
"VerticalMinValue"
,
typeof
(
double
),
typeof
(ChartSmartLabelsStrategyBase),
new
PropertyMetadata(
default
(
double
), OnVerticalMinValueChanged));
06.
07.
private
static
void
OnVerticalMinValueChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
08.
{
09.
var c = obj
as
TwoLineSeriesLabelsStrategy;
10.
c.VerticalMinValue = (
double
)args.NewValue;
11.
}
12.
13.
public
static
void
SetVerticalMinValue(DependencyObject element,
double
value)
14.
{
15.
element.SetValue(VerticalMinValueProperty, value);
16.
}
17.
18.
public
static
double
GetVerticalMinValue(DependencyObject element)
19.
{
20.
return
(
double
)element.GetValue(VerticalMinValueProperty);
21.
}
22.
....
23.
....
24.
....
25.
26.
}
Are there any ways to pass parameters from my ViewModel directly to the label strategy? Or any workarounds to draw labels above 0 value?
Thanks,
Vlad