This question is locked. New answers and comments are not allowed.
I am creating a dashboard application using the Blacklight DragDockPanel and Telerik's RadControls for Silverlight (specifically RadChart and RadGauge) to display charts, gauges, and data tables. I have a Microsoft Access database that I want to use to bind data to the charts and gauges in my application. I do not have the database hosted, but rather just want to connect to it locally.
Right now my charts and gauges just have random data in them. I am creating all my charts and gauges in C# rather than in XAML. This is how I create my charts:
| public RadChart TD_ReturnSales_Last3Years() //bar |
| { |
| SolidColorBrush us_orange = new SolidColorBrush(); |
| us_orange.Color = Color.FromArgb(255, 236, 117, 61); |
| SolidColorBrush us_green = new SolidColorBrush(); |
| us_green.Color = Color.FromArgb(255, 109, 201, 64); |
| SolidColorBrush us_blue = new SolidColorBrush(); |
| us_blue.Color = Color.FromArgb(255, 0, 159, 194); |
| RadChart Chart = new RadChart(); |
| Chart.DefaultView.ChartArea.AxisY.Title = "Percent"; |
| Chart.DefaultView.ChartArea.AxisY.DefaultLabelFormat = "#Y{%}"; //does not work |
| Chart.DefaultView.ChartArea.AxisY.AutoRange = false; |
| Chart.DefaultView.ChartArea.AxisY.AddRange(0, 15, 3); |
| DataSeries dataSeries = new DataSeries(); |
| dataSeries.Definition = new BarSeriesDefinition(); |
| dataSeries.Definition.ShowItemLabels = true; |
| //dataSeries.Definition.ShowItemToolTips = true; |
| dataSeries.Definition.DefaultLabelFormat = "#%"; |
| dataSeries.Definition.Appearance.Fill = us_orange; |
| Random random = new Random(this.GetHashCode() | (int)(DateTime.Now.Ticks)); |
| for (int i = 0; i < 3; i++) |
| { |
| DataPoint dataPoint = new DataPoint(); |
| dataPoint.YValue = random.Next(2,12); |
| dataSeries.Add(dataPoint); |
| } |
| Chart.DefaultView.ChartArea.DataSeries.Add(dataSeries); |
| Chart.DefaultView.ChartArea.AxisX.TickPoints[0].Label = "2006"; |
| Chart.DefaultView.ChartArea.AxisX.TickPoints[1].Label = "2007"; |
| Chart.DefaultView.ChartArea.AxisX.TickPoints[2].Label = "2008"; |
| Chart.DefaultView.ChartLegend.Visibility = Visibility.Collapsed; |
| return Chart; |
| } |
How do I go about setting up this connection and binding the data to my charts? I know that you have to set the DataContext somehow and have looked at all of the examples on the example demo, but I am unsure of how to setup that initial database connection and how to write the queries.
Any help would be appreciated.
Thank you,
Garrett