Map Image not shown
Posted: Tue Aug 30, 2016 6:16 am
Hi, I am trying to put a world map image in the background of the chart. I copied the following from the map example, but the image is not displayed. What have I done wrong?
XAML:
Code: Select all
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
CreateChart();
}
private void CreateChart()
{
//Disable rendering, strongly recommended before updating chart properties
m_chart.BeginUpdate();
//Set background photo
MapBackground mb = new MapBackground(m_chart.ViewXY.Maps);
Uri uri = new Uri(AppDomain.CurrentDomain.BaseDirectory + "world.jpg");
mb.Image = BitmapFrame.Create(uri);
mb.LatitudeMin = -90;
mb.LatitudeMax = 90;
mb.LongitudeMin = -180;
mb.LongitudeMax = 180;
mb.Visible = true;
m_chart.ViewXY.Maps.Backgrounds.Add(mb);
//Setup x-axis
m_chart.ViewXY.XAxes[0].SetRange(-180, 180);
m_chart.ViewXY.XAxes[0].ValueType = AxisValueType.Number;
m_chart.ViewXY.XAxes[0].ScrollMode = XAxisScrollMode.None;
m_chart.ViewXY.XAxes[0].MinorGrid.Visible = false;
m_chart.ViewXY.XAxes[0].MajorGrid.Pattern = LinePattern.Solid;
m_chart.ViewXY.XAxes[0].MajorGrid.Color = Color.FromArgb(40, 0, 0, 0);
m_chart.ViewXY.XAxes[0].ValueType = AxisValueType.MapCoordsDegNESW;
m_chart.ViewXY.XAxes[0].Title.Text = "Longitude";
//Setup y-axis
m_chart.ViewXY.YAxes[0].SetRange(-90, 90);
m_chart.ViewXY.YAxes[0].MinorGrid.Visible = false;
m_chart.ViewXY.YAxes[0].MajorGrid.Pattern = LinePattern.Solid;
m_chart.ViewXY.YAxes[0].MajorGrid.Color = Color.FromArgb(40, 0, 0, 0);
m_chart.ViewXY.YAxes[0].ValueType = AxisValueType.MapCoordsDegNESW;
m_chart.ViewXY.YAxes[0].Title.Text = "Latitude";
//Allow chart rendering
m_chart.EndUpdate();
}
}
Code: Select all
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApplication1"
xmlns:lcu="http://schemas.arction.com/charting/ultimate/" x:Class="WpfApplication1.MainWindow"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid>
<lcu:LightningChartUltimate Name="m_chart"/>
</Grid>
</Window>