Freigeben über


WPF Charting: It's official! [June 2009 release of the WPF Toolkit is now available!]

**

This blog has moved to a new location and comments have been disabled.

All old posts, new posts, and comments can be found on The blog of dlaa.me.

See you there!

Comments

  • Anonymous
    June 25, 2009
    PingBack from http://blogs.msdn.com/delay/archive/2009/06/25/wpf-charting-it-s-official-june-2009-release-of-the-wpf-toolkit-is-now-available.aspx

  • Anonymous
    June 26, 2009
    In order to get the design assemblies to build ... I also had to remove the conditional compilation symbol MWD40 ... as it was complaining about ToolboxCategoryAttribute.

  • Anonymous
    June 26, 2009
    The comment has been removed

  • Anonymous
    June 26, 2009
    cplotts, Thanks for sharing your feedback about the MWD40 symbol! I tried the complete build steps on two different machines and did not need to make that change - but if you did, then maybe some other people will need to as well. :)

  • Anonymous
    July 01, 2009
    how to export the chart created in wpf to excel ?

  • Anonymous
    July 02, 2009
    jaison-joy, What kind of export are you looking for? The chart is created from data the application owns, so if the application wants to export that same data to Excel (via COM/XLS/CSV/etc.), then it can do so. If an image of the chart is desired, that can be obtained via WPF's RenderTargetBitmap. I'm not sure what export functionality people are looking for from the Chart control itself, so if you have specific scenarios in mind, I'd love to hear them!

  • Anonymous
    August 04, 2009
    I used un official WPF charting controls which you mentioed in previous post (http://blogs.msdn.com/delay/archive/2009/03/20/silverlight-charting-remains-just-a-click-away-and-runs-on-wpf-too-chartbuilder-sample-and-source-code-updated-for-charting-s-march-09-release.aspx). Now i am planning to upgrade it. Btw: Can this release supports Expression blend 2.0 ? what is the reason for supports blend3.0 ? is it for maintain compatability btw silverlight and wpf ? Thnaks for your work.

  • Anonymous
    August 05, 2009
    Rajesh, Blend 3 supports Silverlight 3 and Blend 2 supports Silverlight 2. What you probably want to switch to is the official release of Charting in the June 2009 WPF Toolkit which has been specifically verified to work with Blend 3. Here's a link with more information: http://blogs.msdn.com/delay/archive/2009/06/25/wpf-charting-it-s-official-june-2009-release-of-the-wpf-toolkit-is-now-available.aspx Thanks!

  • Anonymous
    August 07, 2009
    How do you copy an entire WPF Chart, including the Title, Legends, Axes and DataPoints (lines, columns or AreaSeries) to the clipboard? The motivation for this question is:

  • User creats a WPF Chart
  • User right-clicks anywhere on the chart to bring up a ContextMenu which says "Copy to Clipboard"
  • User opens PPT (or Word) and pastes the WPF Chart into a PPT slide (or a Word document). Thanks
  • Anonymous
    August 07, 2009
    LunaWPF, The general technique for capturing a part of a WPF application is via the RenderTargetBitmap API which is documented in MSDN here: http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.rendertargetbitmap.aspx This API lets you capture the visuals of any control (like Chart) as an image - which can then be put on the clipboard via the standard clipboard APIs. Hope this helps!

  • Anonymous
    August 13, 2009
    Is there any support planned for XYZ charting? This could apply to any charts that currently display x/y pairs, and is a fairly common feature in advanced charting packages. Apart from that small request, the rest looks great!

  • Anonymous
    August 17, 2009
    Graham, Yes, we'd eventually like to support more chart types - including 3D, etc.. It's just that there have been enough competing priorities that we haven't been able to do so yet. Thanks for your patience!

  • Anonymous
    November 06, 2009
    I like it, but how do you display extreme ranges on a bar chart e.g. January Sales are: 20,000,000 February Sales are: 50 if the value is very small, the bar rectangle may not be drawn, but the value should be displayed as a column annotation. I've seen this on on the graph controls

  • Anonymous
    November 09, 2009
    mks_v1, We don't currently support what are known as "scale breaks" in the axis. However, the following post of mine shows one way to get the annotations you're asking for: http://blogs.msdn.com/delay/archive/2009/07/27/simple-column-labels-you-can-create-at-home-re-templating-the-silverlight-wpf-data-visualization-columndatapoint-to-add-annotations.aspx Hope this helps!

  • Anonymous
    December 24, 2009
    The comment has been removed

  • Anonymous
    December 25, 2009
    The comment has been removed

  • Anonymous
    March 30, 2010
    The comment has been removed

  • Anonymous
    March 31, 2010
    maverickcoder, Yes, this is possible - it sounds like all you need to do is customize the Template for those Charts to remove the extra stuff you don't want (like the Title and Legend).

  • Anonymous
    July 30, 2010
    I'm having trouble with understanding how to tailor the charts mainly due to lack of documentation.  Is there any documentation released yet that provides a reference for the various Charting XAML elements & attributes that are available and how they can be used for charting?  This would be great.  

  • Anonymous
    July 30, 2010
    GregHau, I keep a list of all kinds of Data Visualization resources here: http://cesso.org/r/DVLinks That link points to a list of all my own blog posts on the topic which should provide a pretty thorough overview of how everything works and I know of a lot of people who have managed to achieve great things based on the content I've linked to. :) Hope this helps!

  • Anonymous
    July 30, 2010
    Thanks Delay - I already had this link which is great - do you know if there is a way (re being self-sufficient) to look up reference documentation (online, or in the source of the toolkit if I download it) that could be used to answer a question?  i.e. as opposed to looking for examples where someone else may have done it.   As an example perhaps I've been looking for a way to not have data point markers at each of the data points.  Is there a way I could reference, perhaps starting at chartingToolkit:LineSeries element, to find out what element/attributes I would have to use in my XAML to not have data point markers?   I'm a little new to XAML so perhaps this doesn't help, but it's more about how to lookup/check the specific WPF Toolkit Charting elements/attributes and how to use them that would help me I think, or how to look them up in the source perhaps if the end-user doco isn't ready yet.  Perhaps if I can find the appropriate areas of the source classes I could then set the appropriate configuration in code-behind in C# just to not have to deal with XAML & Charting together (i.e. both are somewhat new to me)?   Thanks

  • Anonymous
    July 30, 2010
    GregHau, I appreciate your attempts to be self-sufficient, but unfortunately there is no official documentation for the Data Visualization assembly, so the links I've collected represent the "unofficial" documentation. That said, the answers to some of what you're asking will become more clear as you become more familiar with Silverlight/XAML/etc.. Regarding the question about removing the DataPoints for a LineSeries, the following post of mine covers that along with some other ideas for improving performance: blogs.msdn.com/.../i-feel-the-need-the-need-for-speed-seven-simple-performance-boosting-tweaks-for-common-silverlight-wpf-charting-scenarios.aspx As for navigating the source code, while I could point you at the relevant areas for specific questions, I don't think there's any general-purpose solution for finding the "right" area automatically. Again, as you develop increasing familiarity with the platform and DataVis, some of this will become easier. That's probably not the most convenient answer for right now, but the good news is that there's every reason to believe things will get easier over time! :)

  • Anonymous
    July 30, 2010
    The comment has been removed

  • Anonymous
    July 30, 2010
    Delay - you don't happen to know if there is a link that covers how to get a graph to dynamically stretch vertically?  For example within a StackPanel (VerticalAlignment=Stretch) that is part of grid (for which the grid row itself, with MaxHeight=Infinity).  It seems like at the moment for me stretching occurs for the graph OK in the horizontal direction, however it's in the vertical direction I'm having the issue.  

  • Anonymous
    July 31, 2010
    GregHau, For the time being, the Data Visualization assembly in the Silverlight and WPF Toolkits is the Charting solution (from Microsoft) that I'd recommend for Silverlight and WPF development. (There are, of course, other Charting solutions for these platforms and I'm sure they're fine choices as well - I'm just addressing your specific question about an offering from Microsoft.) Regarding your layout question, content in a StackPanel with Orientation=Vertical (default) will never stretch vertically. If I'm understanding correctly, you'd see the same behavior with Button that you're seeing with Chart. This is just how StackPanel works - if you want vertical stretching, you probably want to use a Grid (with Rows) instead. Hope this helps!

  • Anonymous
    August 10, 2010
    Hi Delay - mind if I ask if you have any pointers to examples of creating the lines on a chart (lineSeries) programmatically.  So basically just wanted to have the base XAML for the chart, and then programmatically add & remote the lineSeries (I.e. add & remove lines on the graph) as required as data comes into the app.   I did post this question on the forum too at wpf.codeplex.com/.../View.aspx .  Had some example code in the post that I was trying to use but getting exceptions.  Cheers Greg

  • Anonymous
    August 11, 2010
    The comment has been removed

  • Anonymous
    August 11, 2010
    Delay - ah yes the TextToChart should cover it off for me - thanks

  • Anonymous
    August 20, 2010
    I am using the chart in our application. I noticed that when I review the data in XPS file formats. The dataPiont lines are not shown. if the chart is Pie chart or bar chart. it seem to have different fades. I assumed its because of the animation of the datapointseries. If this is correct. How do you disable the animation entirely so that the chart shows on XPS files. Thanks.

  • Anonymous
    August 20, 2010
    I am interested in disabling the datapointseries animation from code behind not XAML. Thanks

  • Anonymous
    August 20, 2010
    Michael, I think this post may be what you're looking for: blogs.msdn.com/.../no-trees-were-harmed-in-the-making-of-this-blog-post-how-to-successfully-print-a-chart-with-the-silverlight-4-beta.aspx

  • Anonymous
    August 20, 2010
    The comment has been removed

  • Anonymous
    August 20, 2010
    [I've answered the duplicate version of Michael's comment above that was added to the other post I reference.]

  • Anonymous
    August 20, 2010
    Hi Delay - is there a way to have a custom Y axis title and range that will apply to all series.  Unless I'm missing something you seem to put this data in with the lineSeries.  The issue I see is then any subsequent titles (even if the same) applied to the 2nd, 3rd series then appear as well.  As I'm programmatically creating the lineSeries's I've had to put a check in the loop to ensure I only put in the lineSeries.DependentRangeAxis in the first lineSeries.  Wondering if there's a better way to add custom Y Axis range/text when you have multiple lines where you want them to share the one Yaxis text description & range details?

  • Anonymous
    August 20, 2010
    GregHau, You might look at adding that Axis to (or specifying it in) the Chart.Axes collection. If they don't have an Axis set directly on themselves via the Series.*Axis properties, Axes will look in the Chart.Axes collection during initialization and use any suitable axis they find inside. Therfore, if you put a viable Axis there before adding/creating the Series, they should all pick it and share it as it sounds like you want them to. :)

  • Anonymous
    August 23, 2010
    Hi Delay, Does the Chart Control support multithreaded application. I am getting the error message "The calling thread cannot access this object because a different thread owns it."  and I am getting this error in the same tread that created the chart controls.

  • Anonymous
    August 23, 2010
    Jonny, WPF (and Silverlight) tend to require that only the "UI thread" is allowed to access UI elements - it sounds like you're bumping into this. You're welcome to do any data processing you'd like on other threads, but when it comes time to set the ItemsSource, manipulate the UI, or make a change that directly affects the UI (ex: invoke a PropertyChanged event), you'll want to switch to the UI thread to avoid the error you're seeing (Dispatcher.BeginInvoke is rather handy for this). There should be plenty of other coverage of this on the web; I don't think what you're seeing is unique to Charting. I hope this helps!

  • Anonymous
    August 24, 2010
    The comment has been removed

  • Anonymous
    August 25, 2010
    Orianne, You can find lots of examples of Charting in my links collection here: http://cesso.org/r/DVLinks Specifically, this post has an example of two lines: blogs.msdn.com/.../silverlight-charting-gets-a-host-of-improvements-silverlight-toolkit-december-08-release-now-available.aspx Regarding a conditional Area chart, that's not supported by default. That said, there are probably some clever ways you might achieve this - and blogging them is already on my TODO list.

  • Anonymous
    August 25, 2010
    The comment has been removed

  • Anonymous
    August 25, 2010
    Jonny, Not directly - but if you set LineSeries.ItemsSource to an instance of ObservableCollection<T>, you can use the Add and Remove methods on that collection to dynamically add and remove items from the Chart whenever you want (as long as you're doing so from the UI thread). Regarding your specific example, I don't understand what LineSeries would be expected to do if given a Y value that's a string - DependentValues are supposed to be able to be compared to each other and are therefore assumed to be doubles. I don't think this relates to your ability to use multiple threads or not - but you'll probably want to be sure you can get the charts you want on a single thread before you start adding more threads. :)

  • Anonymous
    August 25, 2010
    The charts works well in single thread and I am able to preview the XPS generated file for one record. However, the main processing is  multitreaded to facilitate speed as the files generated a in thousands.

  • Anonymous
    September 14, 2010
    The comment has been removed

  • Anonymous
    September 15, 2010
    GregHau, Yes, it's one of the tips in my performance post here: blogs.msdn.com/.../i-feel-the-need-the-need-for-speed-seven-simple-performance-boosting-tweaks-for-common-silverlight-wpf-charting-scenarios.aspx FYI that there are lots of other good Data Visualization resources here: http://cesso.org/r/DVLinks Hope this helps!

  • Anonymous
    September 15, 2010
    Hi Delay - tried this (but with a chartingToolkit:LineDataPoint, not a charting:ScatterDataPoint)  - for some reason the graph isn't picking up the template - I've done the correct thing based on WPF XAML as far as I know however I'm really stuck - I've posted the code, see link, if you had a chance to have a quick look - is there a reason when using the WPFToolkit for charting that the normal XAML template approach would behave differently?  That is if I have under Windows.Resources and using (Style TargetType="chartingToolkit:LineDataPoint") why it wouldn't be picked up by a chartingToolkit:LineSeries? wpf.codeplex.com/.../View.aspx

  • Anonymous
    September 16, 2010
    GregHau, It looks like Cory Plotts is actively helping you on that thread, so I'll hold off for now. :) Though my recommendation would be to try it first the "Charting" way by explicitly setting Series.DataPointStyle to the style you want. If that doesn't work, then something else is getting in the way and it's not an implicit Style issue. If it does work, then we can sort out why implicit Styles wouldn't be working here.

  • Anonymous
    September 29, 2010
    I'd like to specify declaratively in the XAML that I'd like a variable number of LineSeries series. Is this possible?

  • Anonymous
    September 29, 2010
    Eddie, That's not supported by default, but I link to posts by Jeremiah Morrill and Beat Kiener that show ways of doing this in my link collection: http://cesso.org/r/DVLinks

  • Anonymous
    September 30, 2010
    Thanks for the link delay, this one looks particularly promising: blog.thekieners.com/.../databinding-multi-series-charts Do you have a plan to add support for this at a later date?

  • Anonymous
    September 30, 2010
    Eddie, It's on the TODO list - but that list also includes things for the rest of the Silverlight Toolkit and the Windows Phone Toolkit as well... :) If one of those solutions works well for you, it would be a great approach for now.

  • Anonymous
    October 07, 2010
    The comment has been removed

  • Anonymous
    October 07, 2010
    Hi, Delay, I just downloaded source code and was able to step into source code.  It is probably a bug. I made following change in DefinitionSeries.cs (starts line 934). It works now.                      //foreach (DataItem oldDataItem in DataItems.Where(di => (di.SeriesDefinition == definition) && (oldStartingIndex <= di.Index) && (di.Index < oldStartingIndex + oldItems.Count)))                    //{                    //    oldDataItem.Index = -1;                    //    if (null != oldDataItem.DataPoint)                    //    {                    //        oldDataItem.DataPoint.State = DataPointState.Hiding;                    //    }                    //}                    var oldDataItems = DataItems.Where(di => (di.SeriesDefinition == definition) && (oldStartingIndex <= di.Index) && (di.Index < oldStartingIndex + oldItems.Count));                    int counts = oldDataItems.Count();                    for (int i = 0; i < counts; i++)                    {                        DataItem oldDataItem = oldDataItems.ElementAt(i) as DataItem;                        oldDataItem.Index = -1;                        if (null != oldDataItem.DataPoint)                        {                            oldDataItem.DataPoint.State = DataPointState.Hiding;                        }                    }

  • Anonymous
    October 07, 2010
    Xiaoyong, I'm glad to hear you got this working! I'm going to guess that you've customized your DataPoint Template to remove the Hiding VisualStateManager state - which causes the DataPoint to transition to Hidden immediately and should explain why this problem doesn't show up by default. If so, your change is exactly the right fix - I think there's already a bug on this, but I'll double-check right now to be sure. Thanks very much for looking into this and sharing your fix!

  • Anonymous
    October 17, 2010
    hello delay, Thanks for the fantastic blog going. Also you response for queries are great. I got a custom chart which is a combination of pie and scatter chart, which is not industry standard. Will it require some custom code? Also it needs fancy stuff like tool tips, export to pdf/excel and zooming. Also what all dependencies i need to look for while deploying this chart application developed with the toolkit? Will I be able to tweak and generate using the wpf toolkit.   Thank you..

  • Anonymous
    October 18, 2010
    ramh, It sounds like your scenario may be a little more specialized than what's currently supported by the Toolkit Data Visualization offering. It might be a good way to get started, but depending on your zoom needs, you might end up having to write some custom code to do what you want. Regarding dependencies, the only dependency of the WPF Data Visualization assembly is the WPF Toolkit - and both are open source, so you can download all the code and compile/modify them yourself if you want. Hope this helps!

  • Anonymous
    January 14, 2011
    I want to create stack column series. I cannot find the same in the toolkit. please update me on this.

  • Anonymous
    January 15, 2011
    The comment has been removed

  • Anonymous
    February 14, 2011
    Hi, this is a really nice piece of work, thanks for sharing. Is it possibe to add the titles and legend to your "Jelly Charting" example. I tried:                    <charting:LineSeries                    ItemsSource="{Binding Converter={StaticResource JellyConverter}}"                    ...                    TransitionDuration="0">                    <charting:LineSeries.DependentRangeAxis>                        <charting:LinearAxis                                    Orientation="Y"                                    Title="Some Title"                                    Interval="50"                                    ShowGridLines="True"/>                   </charting:LineSeries.DependentRangeAxis>                  ... but unfortunately it didn't work.

  • Anonymous
    February 14, 2011
    Steve B., In the Jelly Charting post (blogs.msdn.com/.../peanut-butter-jelly-time-how-to-create-a-pleasing-visual-effect-with-silverlight-wpf-charting.aspx), I specifically provided a custom ControlTemplate without a Legend and set the Width/Height of the axes to 1 - you could definitely undo those things in order to get closer to a "normal"-looking chart. :)

  • Anonymous
    February 15, 2011
    Thanks a lot, that worked :)

  • Anonymous
    February 22, 2011
    Are the chart controls supported with VS 2010 Premium/ Expression 4 and VB .Net?

  • Anonymous
    February 22, 2011
    Jamie Pattison, Yes, that should work fine. FYI that you might want to start from my Development Release 4 which contains the latest features and fixes from the April 2010 Silverlight Toolkit: blogs.msdn.com/.../phone-y-charts-silverlight-wpf-data-visualization-development-release-4-and-windows-phone-7-charting-sample.aspx But both should work fine. :)

  • Anonymous
    March 25, 2011
    Hi, Great Info here! I was wondering if I could get some advice... I've been able to set up a dynamic chart but for some reason I cannot assign series to particular axes. The problem is that i have many series and I would like to assign them to 2 types of Y axis. I do not want to see the range each time I I add the series. For example: I have A left and right  side Y axis and i want 2 series on the left Y and 2 series on the right Y. I can assign all the left axes in the Axes collection like this:    <DVC:Chart.Axes>      <DVC:LinearAxis Orientation="Y" ShowGridLines="True" Title="Temperature °F" Minimum="0" Maximum="300" Interval="10" Location="Left" /> But the catch is when I try to assign more than one series to the right, I am forced to assign each series with a statement like this :        <DVC:LineSeries.DependentRangeAxis>          <DVC:LinearAxis Orientation="Y" ShowGridLines="True" Title="Humidity %" Minimum="0" Maximum="100" Interval="10" Location="Right" />        </DVC:LineSeries.DependentRangeAxis> This causes more than one rang to show on the right as I am creating an axis for each.   If I do not set this then It will fall through an select the left axis. Ive set the visibility of the axis to hidden but it leaves a gap where it was and if I collapse it, it collapses the series as well. Is there any way to assign a series to an axis like ?:   <DVC:LineSeries Title="Humidity" BoundAxisName="RightSideAxis"> I've attached some code below in case It may help someone      <DVC:LineSeries Title="Humidity" Name="Humidity" ItemsSource="{Binding}" IndependentValueBinding="{Binding Date}" DependentValueBinding="{Binding Value}">        <DVC:LineSeries.DataPointStyle>        </DVC:LineSeries.DataPointStyle>        <DVC:LineSeries.DependentRangeAxis>          <DVC:LinearAxis Orientation="Y" ShowGridLines="True" Title="Humidity %" Minimum="0" Maximum="100" Interval="10" Location="Right" />        </DVC:LineSeries.DependentRangeAxis>      </DVC:LineSeries>      <DVC:LineSeries Title="Wet Temp" Name="WetTemp" ItemsSource="{Binding}" IndependentValueBinding="{Binding Date}" DependentValueBinding="{Binding Value}">        <DVC:LineSeries.DataPointStyle>        </DVC:LineSeries.DataPointStyle>      </DVC:LineSeries>    </DVC:Chart.Series>    <DVC:Chart.Axes>      <DVC:LinearAxis Orientation="Y" ShowGridLines="True" Title="Temperature °F" Minimum="0" Maximum="300" Interval="10" Location="Left" />      <DVC:LinearAxis Orientation="Y" ShowGridLines="True" Title="Humidity %" Minimum="0" Maximum="100" Interval="10" Location="Right" />      <DVC:DateTimeAxis Orientation="X" ShowGridLines="True" IntervalType="Days">        <DVC:DateTimeAxis.AxisLabelStyle>        </DVC:DateTimeAxis.AxisLabelStyle>      </DVC:DateTimeAxis>    </DVC:Chart.Axes>      <DVC:LinearAxis Orientation="Y" ShowGridLines="True" Title="Temperature °F" Minimum="0" Maximum="300" Interval="10" Location="Left" /> But the catch is when I try to assign more than one series to the right, I am forced to assign each series with a statement like this :        <DVC:LineSeries.DependentRangeAxis>          <DVC:LinearAxis Orientation="Y" ShowGridLines="True" Title="Humidity %" Minimum="0" Maximum="100" Interval="10" Location="Right" />        </DVC:LineSeries.DependentRangeAxis> This causes more than one rang to show on the right as I am creating an axis for each.   If I do not set this then It will fall through an select the left axis. Ive set the visibility of the axis to hidden but it leaves a gap where it was and if I collapse it, it collapses the series as well. Is there any way to assign a series to an axis like ?:   <DVC:LineSeries Title="Humidity" BoundAxisName="RightSideAxis"> I've attached some code below in case It may help someone      <DVC:LineSeries Title="Humidity" Name="Humidity" ItemsSource="{Binding}" IndependentValueBinding="{Binding Date}" DependentValueBinding="{Binding Value}">        <DVC:LineSeries.DataPointStyle>        </DVC:LineSeries.DataPointStyle>        <DVC:LineSeries.DependentRangeAxis>          <DVC:LinearAxis Orientation="Y" ShowGridLines="True" Title="Humidity %" Minimum="0" Maximum="100" Interval="10" Location="Right" />        </DVC:LineSeries.DependentRangeAxis>      </DVC:LineSeries>      <DVC:LineSeries Title="Wet Temp" Name="WetTemp" ItemsSource="{Binding}" IndependentValueBinding="{Binding Date}" DependentValueBinding="{Binding Value}">        <DVC:LineSeries.DataPointStyle>        </DVC:LineSeries.DataPointStyle>      </DVC:LineSeries>    </DVC:Chart.Series>    <DVC:Chart.Axes>      <DVC:LinearAxis Orientation="Y" ShowGridLines="True" Title="Temperature °F" Minimum="0" Maximum="300" Interval="10" Location="Left" />      <DVC:LinearAxis Orientation="Y" ShowGridLines="True" Title="Humidity %" Minimum="0" Maximum="100" Interval="10" Location="Right" />      <DVC:DateTimeAxis Orientation="X" ShowGridLines="True" IntervalType="Days">        <DVC:DateTimeAxis.AxisLabelStyle>        </DVC:DateTimeAxis.AxisLabelStyle>      </DVC:DateTimeAxis>    </DVC:Chart.Axes>

  • Anonymous
    March 25, 2011
    Al T., It sounds like the difficulty arises because both Axes are suitable for each Series (otherwise the Series would select the correct one automatically). The thing I'd try is something like this: <DVC:LineSeries ... DependentRangeAxis="{Binding ElementName=MyRightAxis}" /> Basically, instead of defining a new Axis inline (which creates a new instance and leads to the problems you describe), just tell the Series to share the same Axis instance you've already created. This might take a bit of cleverness to ensure the Binding/ElementName lookup resolves correctly, etc., but ought to work as you want once everything's hooked up properly. :) Hope this helps!

  • Anonymous
    May 24, 2011
    Hi Is there a sample for 3d charts ?

  • Anonymous
    May 24, 2011
    sharon, No, sorry; 3D isn't supported at present.

  • Anonymous
    May 26, 2011
    Hi Delay ,I've a problem with exporting the WPF Chart to a JPEG or XPS format. Problem is that while the export goes well, the chart is not scaled, since only a percentage is displayed. but it can be displayed correctly in the WPF application. Here is my test code :            Chart chartView = new Chart();    chartView.BeginInit();            chartView.Width = 300;            chartView.Height = 250;            chartView.Background = Brushes.Azure;            PieSeries pieSeries = new PieSeries();            Binding KeyBind = new Binding("Key");            Binding ValueBind = new Binding("Value");            pieSeries.Title = "Test";            pieSeries.IndependentValueBinding = KeyBind;            pieSeries.DependentValueBinding = ValueBind;    KeyValuePair<object, double>[] itemsSource = new KeyValuePair<object, double>[] { new KeyValuePair<object, double>("Apple", 100.0), new KeyValuePair<object, double>("Orange", 200.0) };    pieSeries.ItemsSource = itemsSource ;    chartView.Series.Add(pieSeries);        chartView.EndInit();          RenderTargetBitmap renderTarget =                new RenderTargetBitmap((int)300,                                    (int)250,                                    96,                                    96,                                    System.Windows.Media.PixelFormats.Pbgra32);            Size tmpSize = new Size(m_PrintWidth, m_PrintHeight);            chartView.Measure(tmpSize);            chartView.Arrange(new Rect(tmpSize));            chartView.UpdateLayout();            renderTarget.Render(chartView);            PngBitmapEncoder encoder = new PngBitmapEncoder();            encoder.Frames.Add(BitmapFrame.Create(renderTarget));            using (FileStream pageOutStream = new FileStream(@"c:pie.png", FileMode.Create, FileAccess.Write))            {                encoder.Save(pageOutStream);                pageOutStream.Close();            } Am i doing wrong ? Thanks  a lot in advance for any hints!

  • Anonymous
    May 30, 2011
    Hi Delay,The code works perfectly if I display the chart in a window first,but if I don't display it in a window,I have got the image to save to file and the data on the X & Y axis legendArea is displayed but the plotArea on the graph are not drawn.

  • Anonymous
    May 31, 2011
    Laozhang, Glad to hear you're making progress! Maybe something in the following post I did on printing a chart will be helpful to you: blogs.msdn.com/.../no-trees-were-harmed-in-the-making-of-this-blog-post-how-to-successfully-print-a-chart-with-the-silverlight-4-beta.aspx

  • Anonymous
    June 01, 2011
    Thanks for your reply. I am trying to create a WPF Chart without XAML in c# code(DLL file) and saving it to file(xps or image) without displaying it on screen. It didn't work.

  • Anonymous
    June 01, 2011
    Laozhang, The techniques I describe shouldn't require the content be displayed on screen to work - and it should work the same whether it's created in code or XAML. Some other ideas: Are m_printWidth/Height in your example correct? Have you tried putting the content on screen to visually verify it? Does it work if printed after that?

  • Anonymous
    June 01, 2011
    Hi Delay, Thanks once more for a speedy response.I modified the code ,it displays perfectly in a WPF application, but when I save it to a xps file, it wasn't outputting the plotArea(legendArea was outputted).       private void CreateChart()        {            Chart chartView = new Chart();            int printWidth = 790;            int printHeight = 1125;            chartView.BeginInit();            chartView.Width = 300;            chartView.Height = 250;            chartView.Background = Brushes.Azure;            PieSeries pieSeries = new PieSeries();            Binding KeyBind = new Binding("Key");            Binding ValueBind = new Binding("Value");            pieSeries.Title = "Test";            pieSeries.IndependentValueBinding = KeyBind;            pieSeries.DependentValueBinding = ValueBind;            KeyValuePair<object, double>[] itemsSource = new KeyValuePair<object, double>[] {            new KeyValuePair<object, double>("Apple", 100.0),            new KeyValuePair<object, double>("Orange", 200.0) };            pieSeries.ItemsSource = itemsSource;            chartView.Series.Add(pieSeries);            chartView.EndInit();            var content = new Border            {                BorderBrush = new SolidColorBrush(Colors.Magenta),                BorderThickness = new Thickness(10),                Child = chartView,            };            // Create container for putting content in the visual tree invisibly            Grid visualTreeContainer = new Grid            {                Width = 300,                Height = 250,                Opacity = 0,            };            // Put content in the visual tree to initialize            visualTreeContainer.Children.Add(content);            using (XpsDocument xpsDocument = new XpsDocument(@"c:test.xps", FileAccess.ReadWrite, CompressionOption.Maximum))            {                XpsDocumentWriter xpsdw = XpsDocument.CreateXpsDocumentWriter(xpsDocument);                // PrintTicket                PrintTicket printTicket = new PrintTicket();                if (printWidth > printHeight)                {                    printTicket.PageOrientation = PageOrientation.Landscape;                }                else                {                    printTicket.PageOrientation = PageOrientation.Portrait;                }                VisualsToXpsDocument visWriter = xpsdw.CreateVisualsCollator(printTicket, printTicket) as VisualsToXpsDocument;                Size size = new Size(printWidth, printHeight);                content.Measure(size);                content.Arrange(new Rect(new Point(), size));                content.UpdateLayout();                visWriter.Write(content);                visWriter.EndBatchWrite();                visualTreeContainer.Children.Remove(content);            }        }

  • Anonymous
    June 02, 2011
    Laozhang, It doesn't look like the code above accomodates for the default delayed fade-in of DataPoint instances that I discuss in blogs.msdn.com/.../no-trees-were-harmed-in-the-making-of-this-blog-post-how-to-successfully-print-a-chart-with-the-silverlight-4-beta.aspx You can give it time to settle or provide a custom (non-fading) Template for the DataPoints. Also, it might be helpful to simulate the measure/arrange pass a couple of times in a row - perhaps running that code just once isn't enough for everything to settle (i.e., if it calls Invalidate as part of layout, the code above won't accomodate that whereas the visual tree would).

  • Anonymous
    June 17, 2011
    The comment has been removed

  • Anonymous
    June 17, 2011
    Taylor, If you want to run the latest Data Visualization assembly code on multiple platforms, you probably want to have a look at my Data Visualization Development Release which provides multiple CSPROJs that do exactly that. :) Here's a link to the latest which brings the April 2010 Silverlight Toolkit implementation to WPF: blogs.msdn.com/.../phone-y-charts-silverlight-wpf-data-visualization-development-release-4-and-windows-phone-7-charting-sample.aspx

  • Anonymous
    June 19, 2011
    Thank you, David!  Awesome work! I tried porting it over myself and there were so many issues -- I look forward to learning how you did this as well!

  • Anonymous
    February 03, 2012
    Hi.. How to databind a chart to a database table

  • Anonymous
    February 03, 2012
    Seevali, Typically, you'll issue some kind of query against the database, form the results into a collection of objects, bind that data to a Series.ItemsSource property, and configure the In/DependentValuePath on the Series appropriately. I give an overview of the Chart-related steps in the following post: blogs.msdn.com/.../announcing-a-free-open-source-charting-solution-for-silverlight-silverlight-toolkit-released-today-at-pdc.aspx Regarding how to get the data out of the database, that's not specific to Charting and you're free to use whatever method (ex: Linq-to-SQL) you'd like. Hope this helps!

  • Anonymous
    March 08, 2012
    I'm inserting a Chart object to a FlowDocument with the code:     Paragraph p = new Paragraph();     InLineUIContainer container = new InlineUIContainer(chart);     p.Inlines.Add(container);     rtb.Document.Blocks.Add(p); When I try to remove it from the FlowDocument with the code:      p.Inlines.Remove(container); I get the following InvalidOperationException:     "Cannot serialize a non-public type     'System.Windows.Controls.DataVisualization.UniqueObservableCollection`1         [System.Windows.Controls.DataVisualization.Charting.IAxis]'." Please advise.

  • Anonymous
    March 09, 2012
    Adolfo A Aguiar, Offhand, I'm not sure why you're seeing that. :( The attempt to serialize isn't coming from the DataVis assembly, so you might look at the call stack to see where it's coming from and why (because deserializing on removal doesn't make sense to me at first glance). You might also download the source code for the DataVis assembly so you can build it yourself and maybe see if marking the relevant type as public is enough to get your scenario working? As far as I know, this isn't an issue normally, so I'm assuming it's related to FlowDocument/InlineUIContainer somehow... Hope this helps!