locked
How to make a line chart in wpf RRS feed

  • Question

  • Hi All,

    I am working on a WPF project based on .Net 3.5, there is a line chart in this project as the follow:

    I find WPF Toolkit is a free control for chart in wpf, so I write code as the follow:

    xmlns:datavis="clr-namespace:System.Windows.Controls.DataVisualization;assembly=System.Windows.Controls.DataVisualization.Toolkit" 
                 xmlns:charting="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
    
    
    <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="10" Grid.Column="1" Grid.Row="0">
                <charting:Chart x:Name="waitingtasks" BorderBrush="Transparent" BorderThickness="0" VerticalAlignment="Stretch" Title="Waiting Tasks">
                    <charting:Chart.TitleStyle>
                        <Style TargetType="datavis:Title">
                            <Setter Property="HorizontalAlignment" Value="Left"/>
                            <Setter Property="Foreground" Value="White"/>
                        </Style>
                    </charting:Chart.TitleStyle>
                    <charting:Chart.LegendStyle>
                        <Style TargetType="datavis:Legend">
                            <Setter Property="Width" Value="0" />
                        </Style>
                    </charting:Chart.LegendStyle>
                    <charting:Chart.Axes>
                        <charting:LinearAxis Orientation="X" Title="Time" Interval="20" ShowGridLines="False"/>
                        <charting:LinearAxis Title="Number of Waiting Tasks" Orientation="Y" Interval="5" ShowGridLines="False"/>
                    </charting:Chart.Axes>
                    <charting:LineSeries DependentValuePath="Value" IndependentValuePath="Key" ItemsSource="{Binding}" IsSelectionEnabled="True" 
                                        AnimationSequence="FirstToLast"/>
                </charting:Chart>

    But I get an error:

    Could not load file or assembly 'WPFToolkit, Version=3.5.40128.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

    It's very wired. Nothing to do with WPFToolkit assembly. 

    Any idea? or Is there other free controls for chart in wpf?

    Thanks.

    Monday, August 12, 2013 10:05 AM

Answers

All replies

  • Hi Vic,

    According to your code, I’ve created a sample project on .Net framework 3.5. Everything is ok in my side.

    For your error message, I suggest you add a reference to WPFToolkit.dll (Not just System.Windows.Controls.Input.Toolkit),

    you can download from this:  You can download it from the link below:
    http://wpf.codeplex.com/

    I've uploaded my project to SkyDrive:
    http://sdrv.ms/18qPYej


    Franklin Chen
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, August 13, 2013 4:37 AM
  • Hi Franklin,

    Thanks for your reply. I think the reason is that this assembly is dependent on WPFToolkit.dll. I use both of them, but their versions are different. This is wired because i see the version of them are the same in VS. Today I compile those two assemblies by myself, and it works. Thanks again. 

    BTW, Are there another good free controls for line chart in wpf?

    • Edited by VicZhang Tuesday, August 13, 2013 8:02 AM
    Tuesday, August 13, 2013 8:01 AM
  • Hi Vic,

    Please check below for another free WPF chart control:
    #WPF chart controls
    http://stackoverflow.com/questions/577278/wpf-chart-controls


    Franklin Chen
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by VicZhang Wednesday, August 14, 2013 2:33 PM
    Tuesday, August 13, 2013 8:24 AM
  • Hi Franklin,

    Thanks for your help. I select to use OxyPlot(an open source chart control, based on .Net 4 or higher) in my project. I do some changes on OxyPlot to fit my project which bases on .Net 3.5. 

    I mark your reply as the answer.

    Wednesday, August 14, 2013 2:36 PM
  • If researching charting, see Gigasoft's WPF .NET Charting.  There's a quick 7 meg demo with 100 examples you can zoom, pan, rotate, customize, export, etc.

    Line charting Wpf RealTime

    Net charting Wpf Surface

    Tuesday, February 18, 2014 5:24 PM
  • FYI: WPFToolkit.dll is not supported by .NET 4.5.

    I may try OxyPlot.

    Saturday, September 5, 2015 7:11 PM
  • Please try LightingChart.  The fastest and most complete chart component for WPF. 

    Real-time scrolling line plot

    • the Fastest charts, magnitudes faster than the other here. See real performance comparison
    • Plotting over 1 Billion data points scrolling line plot, in real-time 
    • Zoomable 2D, 3D and pannable 2D charts, with buttons, key combinations, mouse wheel, touch gestures.
    • 3D charts rotate and there is even a box zoom to zoom specific range from 3D chart 
    • Zoomable polar charts
    • Zoomable Smith charts 
    • Zoomable off-line maps 
    • Zoomable on-line maps 
    • Best features / cost rate

    LightningChart v.7 pictures

    See reviews from happy customers: Click on Reviews. 

    Manufacturer, Arction Ltd, is Visual Studio Industry Partner.  


    Friday, May 13, 2016 7:22 PM