Using D3 Silverlight on WP7

Mar 15, 2012 at 7:30 AM

I'm trying to use the silverlight 0.2 beta on the phone, and am aving difficulty with the scales.

I'm finding that the pixel locations aren't lining up, for example, the grid lines to the labels.

In addition, I'm finding that there are no lines drawn in the top left quadrant.

Here's my code:

ChartPlotterSettings settings = new ChartPlotterSettings();
settings.IsButtonNavigationPresents = false;
settings.IsLegendPresents = false;
chart = new ChartPlotter(settings);
chart.Height = 200;
chart.Width = 480;
chart.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
chart.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch;
chart.VerticalContentAlignment = System.Windows.VerticalAlignment.Stretch;
chart.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
chart.Background = new SolidColorBrush(Colors.Orange);
chart.HorizontalAxis = new NumericAxis();
var va = chart.VerticalAxis = new VerticalAxis();

Point[] test = { new Point(0.0, 0.0), new Point(10.0, 10.0) };

altDataSource = test.AsDataSource<Point>();
altitude = new LineGraph(altDataSource, "Altitude");
altDataSource.SetYMapping(pt => pt.Y);
altDataSource.SetXMapping(pt => pt.X);

altitude.Foreground = new SolidColorBrush(Colors.Black);
altitude.LineColor = Colors.Blue;
altitude.LineThickness = 1;
chart.Children.Add(altitude);

ChartArea.Children.Add(chart);

and my control is placed on a page like this:

...
    <Grid x:Name="LayoutRoot" Background="Transparent">
       <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
	<Grid>
	<Grid.RowDefinitions>
	<RowDefinition />
	<RowDefinition Height="Auto" />			</Grid.RowDefinitions>
	<Grid Height="400" Width="480" Grid.Row="1">
					<StackPanel Orientation="Horizontal" x:Name="ChartArea"  Background="Green" >
	</StackPanel>
	</Grid>
        </Grid>
    </Grid>
</Grid>

Am I doing something wrong, or is the phone just not going to work?