Jump to content
Software FX Community

mgm

Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by mgm

  1. Hello, you helped me with an example of this on a Pie Chart. It worked for a while but has sporadically started throwing exceptions when the chart is clicked. Here is my code and the exception. Please help!private void chrtUnitsByProduct_MouseClick(object sender, HitTestEventArgs e) { if ((e.Point >= 0) && (e.Series >= 0) && (SDBox.SelectedValue != null)) { // Change third chart ItemsSource here using e.DataItemdProduct p = (dProduct)e.DataItem;if (p.Channel != "All Channels") { // MessageBox.Show(c.Channel);DataAccess dao; dao = ( DataAccess)App.Current.FindResource("dao");chrtUnitsByRegion.ItemsSource = dao.dGetDataByRegionForProductChannel((Int16)SDBox.SelectedValue, p.Product, p.Channel); // <TextBlock Text="{Binding Path=DataItem.channel}" Background="Transparent" Foreground="{StaticResource FontBrush}" FontWeight="Bold" FontFamily="Calbiri" FontSize="13" HorizontalAlignment="Center"/> TextBlock tb = new TextBlock(); tb.Text = "Channel: " + p.Channel + ", " + p.Product;tb.Background = Brushes.Transparent; tb.Foreground = ( LinearGradientBrush)App.Current.FindResource("FontBrush");tb.FontWeight = FontWeights.Bold;tb.FontFamily = new FontFamily("Calbiri"); tb.FontSize = 11; tb.HorizontalAlignment = HorizontalAlignment.Center; chrtUnitsByRegion.Titles[1].Content = tb; } } } System.ArgumentOutOfRangeException was unhandled Message="Index was out of range. Must be non-negative and less than the size of the collection.\r\nParameter name: index" Source="mscorlib" ParamName="index" StackTrace: at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource) at System.ThrowHelper.ThrowArgumentOutOfRangeException() at System.Collections.Generic.List`1.get_Item(Int32 index) at ChartFX.WPF.Chart.a(IPaletteObject A_0, ElementColor A_1, ElementColor A_2, ElementColor A_3) at ChartFX.WPF.Chart.b(Boolean A_0, Boolean A_1) at ChartFX.WPF.Chart.a(ToolTipArea A_0) at ChartFX.WPF.Chart.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, OperationType operationType) at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, OperationType operationType, Boolean isInternal) at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value) at ChartFX.WPF.Chart.get_ToolTipArea() at ChartFX.WPF.Chart.c(Point A_0) at ChartFX.WPF.Chart.a(LogicalHighlightableItem A_0, Point A_1) at ChartFX.WPF.Chart.a(Point A_0) at ChartFX.WPF.Chart.a(Object A_0, EventArgs A_1) at System.Windows.Threading.DispatcherTimer.FireTick(Object unused) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler) at System.Windows.Threading.DispatcherOperation.InvokeImpl() at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state) at System.Threading.ExecutionContext.runTryCode(Object userData) at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Windows.Threading.DispatcherOperation.Invoke() at System.Windows.Threading.Dispatcher.ProcessQueue() at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler) at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter) at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg) at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam) at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg) at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame) at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame) at System.Windows.Window.ShowHelper(Object booleanBox) at System.Windows.Window.Show() at System.Windows.Window.ShowDialog() at FivexFive.Window1.DButtonClick(Object sender, RoutedEventArgs e) in C:\Documents and Settings\mmcwhorter\My Documents\Visual Studio 2008\Projects\FivexFive\FivexFive\Window1.xaml.cs:line 48 at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) at System.Windows.UIElement.RaiseEventImpl(RoutedEventArgs args) at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e) at System.Windows.Controls.Button.OnClick() at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e) at System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e) at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget) at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target) at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) at System.Windows.UIElement.ReRaiseEventAs(RoutedEventArgs args, RoutedEvent newEvent) at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e) at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget) at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target) at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) at System.Windows.UIElement.RaiseEventImpl(RoutedEventArgs args) at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted) at System.Windows.Input.InputManager.ProcessStagingArea() at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input) at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport) at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel) at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler) at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter) at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg) at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam) at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg) at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame) at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame) at System.Windows.Threading.Dispatcher.Run() at System.Windows.Application.RunInternal(Window window) at System.Windows.Application.Run(Window window) at System.Windows.Application.Run() at FivexFive.App.Main() in C:\Documents and Settings\mmcwhorter\My Documents\Visual Studio 2008\Projects\FivexFive\FivexFive\obj\Debug\App.g.cs:line 0 at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException: ChartWrapperTest2.zip
  2. Hi, When I change the ItemSource of a chart in code the template is lost that I assigned in xaml. I'm using your Pie2 template and a few other tricks from other posts to apply lines and labels to the pie slices. <cfx:Chart Name="chart1" Gallery="Pie" ItemsSource="{Binding Source={StaticResource SpendByChannelProvider}}" BorderThickness="0" > <cfx:Chart.Titles> <cfx:Title HorizontalAlignment="Left" Margin="5"> <TextBlock Text="Total Marketing Expenses" Background="Transparent" Foreground="{StaticResource FontBrush}" FontWeight="Bold" FontFamily="Calbiri" FontSize="16" HorizontalAlignment="Left"/> </cfx:Title> </cfx:Chart.Titles> <cfx:SeriesAttributes BindingPath="Spend" Template="{StaticResource Pie2}"> <cfx:SeriesAttributes.PointLabels> <cfx:PointLabelAttributes Visibility="Visible"> <cfx:PointLabelAttributes.Template> <DataTemplate> <Grid> <Grid.RowDefinitions> <RowDefinition></RowDefinition> <RowDefinition></RowDefinition> </Grid.RowDefinitions> <Label Content="{Binding Path=DataItem.Channel}" Background="Transparent" Foreground="{StaticResource FontBrush}" FontWeight="Bold" FontFamily="Calbiri" FontSize="12"/> <WrapPanel Grid.Row="1" Orientation="Horizontal" IsHitTestVisible="False" > <Label Content="{Binding Path=DataItem.Spend, Converter={StaticResource fdc}, ConverterParameter='\{0:C\}'}" Background="Transparent" Foreground="{StaticResource FontBrush}" FontFamily="Calbiri" FontSize="9"/> <Label Content ="(" Background="Transparent" Foreground="{StaticResource FontBrush}" FontFamily="Calbiri" FontSize="9"/> <Label Background="Transparent" Foreground="{StaticResource FontBrush}" FontFamily="Calbiri" FontSize="9" HorizontalAlignment="Left" VerticalAlignment="Top"> <Label.Content> <Binding Path="Self" Converter="{StaticResource MyTooltipConverter}" ConverterParameter="%p" /> </Label.Content> </Label> <Label Content ="%)" Background="Transparent" Foreground="{StaticResource FontBrush}" FontFamily="Calbiri" FontSize="9"/> </WrapPanel></Grid> </DataTemplate> </cfx:PointLabelAttributes.Template> </cfx:PointLabelAttributes> </cfx:SeriesAttributes.PointLabels> </cfx:SeriesAttributes> </cfx:Chart> My chart initializes with default data from an ObjectDataProvider class also in xaml. Once the user selects what they want to see from a combobox, I load a new instance of the same class as I used for my ObjectDataProvider from the database and point the Chart ItemSource to it. The chart refreshes with the database data, (albeit not exactly right, but that's another post), then no longer has the template I assigned.DataAccess dao; // this is my database access object // MessageBox.Show(SDBox.SelectedValue.ToString());dao = (DataAccess)App.Current.FindResource("dao");chart1.ItemsSource = dao.dvGetSpendByChannel((Int16)SDBox.SelectedValue); chart1.AllSeries.Template = ( DataTemplate)FindResource("Pie2");Any Ideas? Thanks, Matt
  3. Hello, I'm trying to achieve #2 above but I'm not clear how I should use Content and ContentTemplate properties of SeriesAttributes. I either get a Legend with the marker (pie slice) and no label, or a label with no marker. Please help.<cfx:Chart Name="chart1" ItemsSource="{Binding Source={StaticResource SpendByChannelProvider}}" Gallery="Pie" HorizontalAlignment="Left" Width="388.103" Grid.ColumnSpan="2" Margin="0,0,0,13" Grid.RowSpan="3"> <cfx:SeriesAttributes BindingPath="spend" Template="{StaticResource Pie2}"> <cfx:SeriesAttributes.PointLabels> <cfx:PointLabelAttributes Visibility="Visible"> <cfx:PointLabelAttributes.Template> <DataTemplate> <Label Content="{Binding Path=DataItem.Channel}" Background="Transparent" Foreground="Black" FontFamily="Calbiri" FontSize="12"/> </DataTemplate> </cfx:PointLabelAttributes.Template> </cfx:PointLabelAttributes> </cfx:SeriesAttributes.PointLabels> <cfx:SeriesAttributes.ContentTemplate> <DataTemplate> <TextBlock x:Name="BarText" Text="{Binding Path=DataItem.Channel}" HorizontalAlignment="Left" VerticalAlignment="Center"/> </DataTemplate> </cfx:SeriesAttributes.ContentTemplate> <cfx:SeriesAttributes.Content> <TextBlock x:Name="BarText" Text="{Binding Path=DataItem.Channel}" HorizontalAlignment="Left" VerticalAlignment="Center"/> </cfx:SeriesAttributes.Content> </cfx:SeriesAttributes> <cfx:Chart.LegendBox> <cfx:LegendBox> </cfx:LegendBox></cfx:Chart.LegendBox> </cfx:Chart>
×
×
  • Create New...