beltrams
Members-
Posts
57 -
Joined
-
Last visited
beltrams's Achievements
Newbie (1/14)
0
Reputation
-
Can someone please help on this? Many thanks!
-
Hi JuanC, Here how I ahve soleved the problem, I hope this will help others in the futute: I have an attached property on cfx:Chart binfing to my data source, every time I update the data source I call Chart.ConditonalAttributes.Recalculate. This make the trick and works fie (for my case): public static class ConditionalAttributesFix { #region Fix on ItemsSource change /// <summary> /// Gets the attached dependency property used to apply the fix /// </summary> public static readonly DependencyProperty OnItemsSourceChangeProperty = DependencyProperty.RegisterAttached( "OnItemsSourceChange", typeof(IEnumerable), typeof(ConditionalAttributesFix), new UIPropertyMetadata(null, OnOnItemsSourceChangePropertyChanged) ); /// <summary> /// Gets the attached dependency property value used to apply the fix /// </summary> public static IEnumerable GetOnItemsSourceChange(DependencyObject obj) { Contract.Requires(obj != null); var obj_tmp = obj.GetValue(OnItemsSourceChangeProperty); if (obj_tmp == null) throw new InvalidOperationException("Dependency object value must not be null"); return (IEnumerable)obj_tmp; } /// <summary> /// Sets the attached dependency property value used to apply fix /// </summary> public static void SetOnItemsSourceChange(DependencyObject obj, IEnumerable value) { Contract.Requires(obj != null); obj.SetValue(OnItemsSourceChangeProperty, value); } static void OnOnItemsSourceChangePropertyChanged(DependencyObject dpo, DependencyPropertyChangedEventArgs args) { if (dpo == null) return; Chart el = dpo as Chart; if (el == null) throw new InvalidCastException("Object of type \"Chart\" expected"); if (args.NewValue != null) { el.ConditionalAttributes.Recalculate(); } } #endregion }} Cheers.
-
I think this will helps! Regards.
-
Hi JuanC, I have found an hack that, at least for me, works: I attach the following attached property to the textbox I use as template for the PointLabeAttribute: public static class DataLabelPositionFixForGantt { /// <summary> /// Gets the attached dependency property used to apply the overridden position /// </summary> public static readonly DependencyProperty ChartTypeProperty = DependencyProperty.RegisterAttached( "ChartType", typeof(string), typeof(DataLabelPositionFixForGantt), new UIPropertyMetadata(string.Empty, OnChartTypePropertyChanged) ); /// <summary> /// Gets the attached dependency property value used to apply overridden position /// </summary> public static string GetChartType(DependencyObject obj) { Contract.Requires(obj != null); var obj_tmp = obj.GetValue(ChartTypeProperty); if (obj_tmp == null) throw new InvalidOperationException("Dependency object value must not be null"); return (string)obj_tmp; } /// <summary> /// Sets the attached dependency property value used to apply red condition /// </summary> public static void SetChartType(DependencyObject obj, string value) { Contract.Requires(obj != null); obj.SetValue(ChartTypeProperty, value); } static void OnChartTypePropertyChanged(DependencyObject dpo, DependencyPropertyChangedEventArgs args) { if (dpo == null) return; TextBlock el = dpo as TextBlock; if (el == null) throw new InvalidCastException("Object of type \"TextBlock\" expected"); if (args.NewValue is string == false) return; if ((string)args.NewValue == WidgetTypes.Gantt.Code) { var cont = el.FindVisualParent<ContentPresenter>(); if (cont == null) throw new InvalidCastException("Object of type \"ContentPresenter\" expected"); var pn = new PropertyChangeNotifier(cont, Canvas.LeftProperty); pn.ValueChanged += OnCanvasLeftChanged; cont.Loaded += OnLoaded; } else { var cont = el.FindVisualParent<ContentPresenter>(); if (cont == null) throw new InvalidCastException("Object of type \"ContentPresenter\" expected"); var pn = new PropertyChangeNotifier(cont, Canvas.LeftProperty); pn.ValueChanged -= OnCanvasLeftChanged; cont.Loaded -= OnLoaded; } } static void OnCanvasLeftChanged(object sender, EventArgs e) { PropertyChangeNotifier notifier = sender as PropertyChangeNotifier; if (notifier == null) throw new InvalidCastException("Object of type \"PropertyChangeNotifier\" expected"); UIElement el = notifier.PropertySource as UIElement; if (el == null) throw new InvalidCastException("Object of type \"UIElement\" expected"); if (Canvas.GetLeft(el) < 9) Canvas.SetLeft(el, 9); } static void OnLoaded(object sender, EventArgs e) { UIElement el = sender as UIElement; if (el == null) throw new InvalidCastException("Object of type \"UIElement\" expected"); if (Canvas.GetLeft(el) < 9) Canvas.SetLeft(el, 9); } }} I hope this will help others in the future. Cheers!
-
Dear Forum, I have the followong settings for a Gantt chart: Anchor="Center" HorizontalAlignment="Center" VerticalAlignment="Center" As result I have the attached screenshot. As you can see, labels for small Gantt bars are cutted, they should be 8, 16 and 46 but you cannot read it. I have tried setting the offset but I doesnt work, does it work with Gantt? Anything I can do?
-
Hello JuanC, I would like to 1) set the decimals I want to see on the point label (not the axis, the point in the plottable area), ideally with binding to my chart point (which is a class with Y and X + other stuff). 2) set the text to be vertical for bars (I have raised a separate forum discussion for this). Thanks, Simone
-
Dear Forum, Is it possible to have vertical point labels on each bar in the bar chart? Thanks!
-
Dear Forum, Any way I can format the PointLabelAttribute? I have tried settings PointLabelAttribute.Template to a textbox, it works but I lose the labels on 3D bars. Ideally I would like to bind the format to the point in my view model but I can set it in XAML if it is not possible. Many thanks.
-
Dear Forum, If a pie chart has different axis/series one of the option is show small pies i tumbnail and the user can select which one to see. Is it possible to style the thumbnail to show the name only (no small pie) and maybe to add a vertical scrollbar to that so i can scroll the items? thanks, Simone
-
Dear Forum, Is it posible to create a Pie chart but with a missing slice? basically an uncompleted pie... Many thanks, Simone
-
Dear Support forum, I have a chart where I use binding for both Chart Gallery and ItemsSource. Chaging the type from Pie to Bar I get the following exception, please note that this is only changing from Pie to something else and not viceversa. After the exception (if I catch it) I see the chart rendered correctly (it looks like at least). Unable to cast object of type 'o' to type 'l'. Error Stack: at ChartFX.WPF.Data.CrosstabTransform.n.a(Object A_0)at ChartFX.WPF.Internal.ColumnGetter.GetString(Object obj)at ChartFX.WPF.AxisLabelAttributes.a(DataGetter& A_0, ILabelCollection A_1, Int32 A_2, Object A_3, Type A_4, NotifyCollectionChangedAction A_5)at ChartFX.WPF.AxisLabelAttributes.a(Int32 A_0, Object A_1, Type A_2, NotifyCollectionChangedAction A_3)at ChartFX.WPF.Axis.a(Int32 A_0, Object A_1, Type A_2, NotifyCollectionChangedAction A_3)at ChartFX.WPF.Axis.e(Boolean A_0)at ChartFX.WPF.Chart.y()at ChartFX.WPF.Chart.MeasureOverride(Size constraint)at System.Windows.FrameworkElement.MeasureCore(Size availableSize)at System.Windows.UIElement.Measure(Size availableSize)at System.Windows.ContextLayoutManager.UpdateLayout()at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)at System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)at System.Windows.Media.MediaContext.AnimatedRenderMessageHandler(Object resizedCompositionTarget)at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler) Any help please? I am on chart fx for wpf 8.0.4247.25815. Thanks!
-
Done it! Many many thanks!
-
Oh... Many thanks JuanC... I havent noticed that grey line before... Please, can I apply those solution in xaml? I don't have code behind... Many thanks again!
-
Hi JuanC, here a part of our code on how we do this: XAML: <Cfx:Chart x:Name="WidgetChart" ItemsSource="{Binding Path=ReportData, Mode=OneWay}"> C#:public IList<ChartableReportRow> ReportData { get { return _reportData; } private set { _reportData = value; NotifyPropertyChanged(() => this.ReportData); } } and to set it I do: this.ReportData = new Collection<ChartableReportRow>( (from row in reportList select new ChartableReportRow(row)).ToList() ); so it should be a new IList every time...