Search code examples
c#silverlightazurewcf-ria-services

Getting error while adding data to Silverlight charts?


I tried to add values to a silverlight line chart. For that i created a line chart and then the data in that chart is being added using wcf ria services.

Everthing works fine but when i try to run my website it loads some dummy data in the chart. There is no data like that in my windows azure sql table. It access the azure sql table and works fine but the values are not same in my database.

To show access the database from azure app, i used ado.net entity model and which created a waterinfodomain and i used this code and similar of other line charts.

I used :

    private GetTemprature()
            {
                //shows and gives garden uses from sql table
                context = new WaterDomainContext();
                context.FarmTemps.Clear();
                var query = context.GetFarmTempsQuery();
                LoadTemp = context.Load<FarmTemp>(query);
                LoadTemp.Completed += new EventHandler(LoadTemp_Completed);
            }

            private void LoadTemp_Completed(object sender, EventArgs e)
            {
                //Draw values from a table for Performance
                List<Temprature> tmp = new List<Temprature>();
                if (LoadTemp.Entities != null || LoadTemp.Entities.Count() > 0)
                {
                    foreach (FarmTemp item in LoadTemp.Entities)
                    {
                        tmp.Add(new Temprature()
                        {
                            Temp = (float)(item.Temp),
                            Date = Convert.ToDateTime(item.ODate)
                        });
                    }
                }
                LineSeries tmpv = FarmCondtion.Series[0] as LineSeries;
                tmpv.ItemsSource = tmp;

            }

I have added this snapshot of what chart i am getting here : https://i.sstatic.net/RC2zV.png

Now you can see the dates are not in regular order [Also these are not the date which are in my database] and only Dots are shown instead of lines. But my database does have only regular values of date for last seven days and other values.

Why this is happening

Please tell me

Thanks


Solution

  • You mentioned the same data works fine in one chart, but not in another. Are there any differences between the two charts? I think the issue is on the client side, as you’ve verified the data is fine in both database and one of the chart. So please focus on the client side now, check how you configure the charts’ data source. By the way, as far as I can tell from the screenshot, the date is in order. It starts from 11/1/2011, goes to 12/1/2011, and then 1/1/2012, all the way to 10/1/2012. The chart is a little small, so the labels are displayed on two lines. Please do not read the first line and then the second line. Instead, read the two lines together, from left to right. Something like:

    1   3   5
      2    4   6
    

    If you mean the date should not be in the future, then please check if you have any code that may alter the dates.

    Best Regards,

    Ming Xu.