This question is locked. New answers and comments are not allowed.
Hi,
I am trying to create custom label format but I have a problem when there is only 1 record in my dataset. For more than 1 record the label works normally.
XAML Code:
Convert Override Method:
Check the attached chart image to see the issue. The X-axis labels are repeated with the value of the dataset.
Any help will be appreciated.
Thanks,
Parth
I am trying to create custom label format but I have a problem when there is only 1 record in my dataset. For more than 1 record the label works normally.
XAML Code:
<Setter Property="Template"> <Setter.Value><ControlTemplate TargetType="telerik:AxisLabel2D"> <?SILVERLIGHT BEGIN?> <primitives:LayoutTransformControl x:Name="PART_LayoutTransformControl" VerticalAlignment="{TemplateBinding VerticalAlignment}" HorizontalAlignment="{TemplateBinding HorizontalAlignment}"> <primitives:LayoutTransformControl.Content> <TextBlock Style="{TemplateBinding ItemLabelStyle}" Text="{Binding Converter={StaticResource LabelConverter}}" /> </primitives:LayoutTransformControl.Content> <primitives:LayoutTransformControl.LayoutTransform> <RotateTransform x:Name="PART_RotateTransform" /> </primitives:LayoutTransformControl.LayoutTransform> </primitives:LayoutTransformControl><?SILVERLIGHT END?></ControlTemplate></Setter.Value></Setter>Convert Override Method:
public class LabelConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { string returnValue; TickPoint tickPoint = value as TickPoint; int pkIndex = 0; switch ((value as TickPoint).LabelFormat) { case "CustomTopComponentFormat": pkIndex = (value as TickPoint).Label.IndexOf("Component_CapitolItem_PK_Sort"); returnValue = (value as TickPoint).Label.Substring(0, pkIndex); break; case "CustomStdDevFormat": pkIndex = (value as TickPoint).Label.IndexOf("Component_Item_FK"); returnValue = (value as TickPoint).Label.Substring(0, pkIndex); break; case "AggregateShortName": if ((value as TickPoint).Label != null) { string[] lines = (value as TickPoint).Label.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries); if (lines.Count() > 1) returnValue = string.Concat(lines[0], "\n", lines[1]); else returnValue = lines[0]; break; } else { returnValue = null; break; } case "SmartMoney": double money; if (double.TryParse((value as TickPoint).Value.ToString(), out money)) { string[] dec = money.ToString("C0").Split(new char[] {','}); switch (dec.Count()) { case 2: returnValue = string.Concat((money / 1000.0).ToString("$###.#"), "k"); break; case 3: returnValue = string.Concat((money / 1000000.0).ToString("$###.#"), "mil"); break; case 4: returnValue = string.Concat((money / 1000000000.0).ToString("$###.#"), "bil"); break; case 5: returnValue = string.Concat((money / 1000000000000.0).ToString("$###.#"), "trl"); break; default: returnValue = money.ToString("C0"); break; } } else returnValue = (value as TickPoint).Value.ToString(); break; default: if (string.IsNullOrWhiteSpace((value as TickPoint).LabelFormat)) returnValue = (value as TickPoint).Value.ToString(); else returnValue = (value as TickPoint).Value.ToString((value as TickPoint).LabelFormat); break; } return returnValue; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return ""; } }Check the attached chart image to see the issue. The X-axis labels are repeated with the value of the dataset.
Any help will be appreciated.
Thanks,
Parth