Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I figured it out. Heres the XAML for the chart.</p> <pre><code> &lt;toolkit:Chart x:Name="barStyledChart" Foreground="#FF579ED4" Style="{StaticResource GreenFxChartStyle}" FontSize="8" Width="290" Height="170" BorderThickness="0"&gt; &lt;toolkit:Chart.Axes&gt; &lt;toolkit:LinearAxis ShowGridLines="True" Orientation="X" Interval="1"&gt; &lt;toolkit:LinearAxis.GridLineStyle&gt; &lt;Style TargetType="Line"&gt; &lt;Setter Property="Stroke" Value="#FF579ED4"&gt;&lt;/Setter&gt; &lt;/Style&gt; &lt;/toolkit:LinearAxis.GridLineStyle&gt; &lt;/toolkit:LinearAxis&gt; &lt;toolkit:LinearAxis ShowGridLines="True" Orientation="Y" Location="Left" Minimum="0" Maximum="200"&gt; &lt;toolkit:LinearAxis.GridLineStyle&gt; &lt;Style TargetType="Line"&gt; &lt;Setter Property="Stroke" Value="#FF032F50"&gt;&lt;/Setter&gt; &lt;/Style&gt; &lt;/toolkit:LinearAxis.GridLineStyle&gt; &lt;/toolkit:LinearAxis&gt; &lt;/toolkit:Chart.Axes&gt; &lt;toolkit:ColumnSeries Background="#FF53C023" AnimationSequence="FirstToLast" DependentValuePath="X" IndependentValuePath="Y"&gt; &lt;toolkit:ColumnSeries.ItemsSource&gt; &lt;PointCollection&gt; &lt;Point&gt;100,2000&lt;/Point&gt; &lt;Point&gt;105,2001&lt;/Point&gt; &lt;Point&gt;98,2002&lt;/Point&gt; &lt;Point&gt;88,2003&lt;/Point&gt; &lt;Point&gt;150,2004&lt;/Point&gt; &lt;Point&gt;125,2005&lt;/Point&gt; &lt;Point&gt;93,2006&lt;/Point&gt; &lt;Point&gt;112,2007&lt;/Point&gt; &lt;Point&gt;145,2008&lt;/Point&gt; &lt;Point&gt;165,2009&lt;/Point&gt; &lt;Point&gt;173,2010&lt;/Point&gt; &lt;Point&gt;168,2011&lt;/Point&gt; &lt;Point&gt;160,2012&lt;/Point&gt; &lt;Point&gt;164,2013&lt;/Point&gt; &lt;Point&gt;158,2014&lt;/Point&gt; &lt;/PointCollection&gt; &lt;/toolkit:ColumnSeries.ItemsSource&gt; &lt;toolkit:ColumnSeries.DataPointStyle&gt; &lt;Style TargetType="toolkit:ColumnDataPoint"&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="toolkit:ColumnDataPoint"&gt; &lt;Grid Width="10"&gt; &lt;Border BorderBrush="White" BorderThickness="1"&gt; &lt;Rectangle Fill="#FF53C023" Opacity=".8"&gt;&lt;/Rectangle&gt; &lt;/Border&gt; &lt;/Grid&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; &lt;/toolkit:ColumnSeries.DataPointStyle&gt; &lt;/toolkit:ColumnSeries&gt; &lt;/toolkit:Chart&gt; </code></pre> <p>and heres the XAML style for it</p> <pre><code>&lt;Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit" xmlns:datavis="clr-namespace:System.Windows.Controls.DataVisualization" xmlns:chartingprimitives="clr-namespace:System.Windows.Controls.DataVisualization.Charting.Primitives;assembly=System.Windows.Controls.DataVisualization.Toolkit" xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows" xmlns:SampleData="clr-namespace:Expression.Blend.SampleData.ProgressionSequenceData" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="SilverlightChartScratchpad.App"&gt; &lt;Application.Resources&gt; &lt;SampleData:ProgressionSequenceData x:Key="ProgressionSequenceData" d:IsDataSource="True"/&gt; &lt;Style x:Key="GreenFxChartStyle" TargetType="toolkit:Chart" &gt; &lt;Setter Property="BorderBrush" Value="Black" /&gt; &lt;Setter Property="BorderThickness" Value="0" /&gt; &lt;Setter Property="IsTabStop" Value="False" /&gt; &lt;Setter Property="Padding" Value="10" /&gt; &lt;Setter Property="Background"&gt; &lt;Setter.Value&gt; &lt;LinearGradientBrush EndPoint="0.352,1.144" StartPoint="0.352,-0.161"&gt; &lt;GradientStop Color="#FF0585D6" Offset="0.268"/&gt; &lt;GradientStop Color="#FF01336E" Offset="0.847"/&gt; &lt;/LinearGradientBrush&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;Setter Property="TitleStyle"&gt; &lt;Setter.Value&gt; &lt;Style TargetType="toolkit:Title"&gt; &lt;Setter Property="Margin" Value="0" /&gt; &lt;Setter Property="Width" Value="0"/&gt; &lt;Setter Property="Height" Value="0"/&gt; &lt;/Style&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;Setter Property="LegendStyle"&gt; &lt;Setter.Value&gt; &lt;Style TargetType="toolkit:Legend"&gt; &lt;Setter Property="Margin" Value="0" /&gt; &lt;Setter Property="Width" Value="0"/&gt; &lt;Setter Property="Height" Value="0"/&gt; &lt;/Style&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;Setter Property="ChartAreaStyle"&gt; &lt;Setter.Value&gt; &lt;Style TargetType="Panel"&gt; &lt;Setter Property="MinWidth" Value="100" /&gt; &lt;Setter Property="MinHeight" Value="75" /&gt; &lt;/Style&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;Setter Property="PlotAreaStyle"&gt; &lt;Setter.Value&gt; &lt;Style TargetType="Grid"&gt; &lt;Setter Property="Background" Value="Transparent"&gt;&lt;/Setter&gt; &lt;/Style&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="toolkit:Chart"&gt; &lt;Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}"&gt; &lt;Grid&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="Auto" /&gt; &lt;RowDefinition Height="*" /&gt; &lt;/Grid.RowDefinitions&gt; &lt;toolkit:Title Content="{TemplateBinding Title}" Style="{TemplateBinding TitleStyle}" /&gt; &lt;!-- Use a nested Grid to avoid possible clipping behavior resulting from ColumnSpan+Width=Auto --&gt; &lt;Grid Grid.Row="1" Margin="0,0,0,0"&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="*" /&gt; &lt;ColumnDefinition Width="Auto" /&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;toolkit:Legend x:Name="Legend" Header="{TemplateBinding LegendTitle}" Style="{TemplateBinding LegendStyle}" Grid.Column="1" /&gt; &lt;chartingprimitives:EdgePanel x:Name="ChartArea" Style="{TemplateBinding ChartAreaStyle}"&gt; &lt;Grid Canvas.ZIndex="-1" Style="{TemplateBinding PlotAreaStyle}" /&gt; &lt;Border Canvas.ZIndex="10" BorderBrush="#FF032F50" BorderThickness="0,0,0,1" /&gt; &lt;/chartingprimitives:EdgePanel&gt; &lt;/Grid&gt; &lt;/Grid&gt; &lt;/Border&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; &lt;/Application.Resources&gt; </code></pre> <p></p> <p>The trick is to create two LinearAxis inside the Chart.Axes collection and hide the second axis label. Also, you need to set the interval which in my case is fixed to 1.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload