I have a problem with "Line series" silverlight graph from the Silverlight toolkit, where i spit out total views and week number.
the problem is: the week numbers are sorted and start from 01 and end at 53 in the graph, though it starts at 05 ?
I have two javascript functions with the arrays which to populate from.
function weeks() {
return '05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,
30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,01,02,03,04';
}
function showings() {
return '1915,1840,1953,1873,1963,2337,2284,3258,3973,3274,
2923,2857,2330,2504,2250,4436,4899,5994,4261,2815,4648,3221,
2693,2790,3135,3929,3888,4023,5037,6175,5809,7600,4678,3723,
3821,3673,3893,3828,3557,4720,4480,3930,4011,3353,3209,2862,
3036,2548,2863,2888,3679,3826,3600';
}
Xaml
<UserControl.Resources>
<Style x:Key="GooglePolylineStyle" TargetType="Polyline">
<Setter Property="StrokeThickness" Value="3"/>
</Style>
<Style x:Key="GoogleLineDataPointStyle" TargetType="charting:LineDataPoint">
<Setter Property="Background" Value="#6A8FDA" />
<Setter Property="Foreground" Value="#6A8FDA" />
<Setter Property="IsTabStop" Value="False"/>
<Setter Property="BorderThickness" Value="0"/>
</Style>
<Style x:Key="GoogleChart" TargetType="charting:Chart">
<Setter Property="PlotAreaStyle">
<Setter.Value>
<Style TargetType="Grid">
<Setter Property="Background" Value="Black" />
</Style>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<Grid x:Name="LayoutRoot" Background="Black">
<chartingToolkit:Chart x:Name="chart" Width="473" Height="250" Style="{StaticResource GoogleChart}">
<chartingToolkit:Chart.LegendStyle>
<Style TargetType="DataVisualization:Legend">
<Setter Property="Width" Value="0"/>
<Setter Property="Height" Value="0"/>
</Style>
</chartingToolkit:Chart.LegendStyle>
<chartingToolkit:Chart.Series>
<chartingToolkit:LineSeries ItemsSource="{Binding}"
DependentValuePath="Value"
IndependentValuePath="Key"
AnimationSequence="FirstToLast"
Title="Visninger"
PolylineStyle="{StaticResource GooglePolylineStyle}"
DataPointStyle="{StaticResource GoogleLineDataPointStyle}" />
</chartingToolkit:Chart.Series>
<chartingToolkit:Chart.Axes>
<chartingToolkit:LinearAxis Orientation="Y" Title="Total views" Foreground="White">
<chartingToolkit:LinearAxis.AxisLabelStyle>
<Style TargetType="chartingToolkit:AxisLabel">
<Setter Property="Foreground" Value="White" />
<Setter Property="StringFormat" Value="{}{0:N0}"/>
</Style>
</chartingToolkit:LinearAxis.AxisLabelStyle>
</chartingToolkit:LinearAxis>
<chartingToolkit:CategoryAxis Orientation="X" Title="Week no." Foreground="White">
<chartingToolkit:CategoryAxis.AxisLabelStyle>
<Style TargetType="chartingToolkit:AxisLabel">
<Setter Property="Foreground" Value="White" />
</Style>
</chartingToolkit:CategoryAxis.AxisLabelStyle>
</chartingToolkit:CategoryAxis>
</chartingToolkit:Chart.Axes>
</chartingToolkit:Chart>
</Grid>
Xaml.cs
var weeks = (string)HtmlPage.Window.Invoke("weeks", "");
var mails = (string)HtmlPage.Window.Invoke("showings", "");
string[] weeksArr = weeks.Split(',');
string[] mailsArr = mails.Split(',');
var pairDic = new Dictionary<string, int>();
var i = 0;
while (i < weeksArr.Length && i < mailsArr.Length)
{
pairDic.Add(weeksArr[i], int.Parse(mailsArr[i]));
i++;
}
chart.DataContext = pairDic;
I'm totally clueless?
//Finnbogi