Page 1 of 1

Customize Admin Dashboard

Posted: Fri Sep 05, 2008 10:55 pm
by CGrouse
By Default, the top left corner it shows

Past 7 Days and Past 6 Months

Any way to add in the Month to date? or even Year to Date?

Thanks

Chris

Re: Customize Admin Dashboard

Posted: Sat Sep 06, 2008 8:02 am
by jmestep
It looks like you might be able to do it in Admin/Dashboard/SalesOverTime.ascs.cs by adding two sections of code using the following that is already there as a pattern.

Code: Select all

   private void initMonthChart(bool forceRefresh)
    {
        string cacheKey = "39C69D16-CD5A-4287-8DD4-E21019A78B8E";
        CacheWrapper cacheWrapper = Cache[cacheKey] as CacheWrapper;
        if (forceRefresh || (cacheWrapper == null))
        {
            //LOAD VIEWS
            SortableCollection<KeyValuePair<DateTime, decimal>> salesByMonth = ReportDataSource.GetSalesForPastMonths(6, true);
            //BUILD BAR CHART
            WebChart.ColumnChart chart = (ColumnChart)SalesByMonthChart.Charts[0];
            for (int i = 0; i < salesByMonth.Count; i++)
            {
                int roundedTotal = (int)Math.Round(salesByMonth[i].Value, 0);
                chart.Data.Add(new ChartPoint(salesByMonth[i].Key.ToString("MMM yy"), roundedTotal));
            }
            chart.MaxColumnWidth = 30;
            //BIND THE CHART
            SalesByMonthChart.RedrawChart();
            //CACHE THE DATA
            cacheWrapper = new CacheWrapper(SalesByMonthChart.ImageID);
            Cache.Remove(cacheKey);
            Cache.Add(cacheKey, cacheWrapper, null, DateTime.UtcNow.AddMinutes(5).AddSeconds(-1), TimeSpan.Zero, System.Web.Caching.CacheItemPriority.High, null);
        }
        else
        {
            //USE CACHED VALUES
            SalesByMonthChart.ImageID = (string)cacheWrapper.CacheValue;
        }
        _CacheDate = cacheWrapper.CacheDate;
    }
As a start, try changing
private void initMonthChart(bool forceRefresh) to another name, the cache key, and then ReportDataSource.GetSalesForPastMonths(6, true); to 12 instead of 6 for months

Re: Customize Admin Dashboard

Posted: Mon Sep 08, 2008 10:18 am
by evanb@firefold.com
Is there any significance in generating a new cache key? Or can you simply just change it to another string?
Besides renaming the section of code to my value, what else (if anything) needs to be changed?
Which values need to be linked to the SalesOverTime.ascx file?

Re: Customize Admin Dashboard

Posted: Mon Sep 08, 2008 11:16 am
by jmestep
On the cache key- I think it would have to be different because you are storing different data. On generating it, I just don't know. Maybe someone at Able can chime in.
On other changes that might be necessary, I didn't notice any, but I didn't try the code for real. I have a very "scientific" method when I do something like that- I change it and see what broke, what kind of error messages I got and fix what broke.