I’m using Microsoft Chart extensions that ship with VS 2010. This suits my needs well, but I’ve run into an annoyance and am looking for a more elegant solution.
When charting a line graph, to achieve a continuous line, I require data for all X coordinates. My dataset is for number of sales by employee by month, where sales count is on the Y and month is on the X. The problem arises where no data is returned for an X value (ie. An employee took a month off)…so the line is not continuous.
I’m not sure if there is a setting I’ve overlooked in the Chart control, but my inelegant solution is to create ‘fake’ zero sales data for the months the employee posted no sales.
I’m using a stored procedure in MS SQL to create my dataset, where each column is a month and each row is for an employee. I create a new series in the Chart control for each employee then.
In order to capture my zero sales months, I have created a temp table in SQL.
CREATE TABLE @tblMonth (myMonth nvarchar(10), defaultCount int)
INSERT INTO @tblMonth VALUES (‘January’, 0)
…
INSERT INTO @tblMonth VALUES (‘December’, 0)
I then perform a join of my temp table on my actual data record and use
ISNULL (realData.Count, tblMonth.defaultCount)
To get my ‘fake’ zero sales data.
This works…but FEELS really kludgy to me…I can’t help but feel I’ve overlooked something simple that would better suit my purposes. Again, I’ve got this working…but always looking for better ways of doing things and expand my knowledge base….so if anyone has suggestions of how better to accomplish the above, I’d love some suggestions or feedback.