Stacked BarChart - data not lining up?
Posted: Tue May 15, 2007 10:48 am
Hi there - I have a stacked barchart and am finding that I'm having difficulty getting my data to line up correctly without lots of programming work on my part. I'm thinking I must be doing something obviously wrong and am after a few pointers.
Essentialy I want to have bars for: Jan Wk1, Jan Wk2, Jan Wk3, Jan Target, Feb Wk1 .... Feb Target etc.
For each bar I have 4 stacked values, Sales Complete, Sales In Progress, Sales Remaining, Target. The target should be zero for each of the weeks as there aren't any weekly targets but have a number for the "Month" Target bar. Hopefully you can visualise that.
Based on the avbove, my data is calculated in memory and I output to each of the series - the target series is Null for each of the WkX bars and has a positive value for the Monthly target bar (so you can easily see how close sales were to the targets) so I loop through each of my months and do (in pseudo code):
for each week targetSeries addNull (week name).
targetSeries add (month target), (month name + ' Target')
(I repeat the above for 4 months - e.g. a Quarter).
I wasn't expecting to have to write out the null values above but I found that if I didn't do this - my target values didn't line up for each bar.
Next I need to write out the actual sales - so I do something similar
for each week actualSalesSeries add week sales, week name
However this is where I hit the problem - I was kind of expecting to be able to write these values in any order, and if I provided the same label name then the items would just go into the correct columns. This doesn't seem to the be case - I seem to need to sort my data so that I process Wk1 data first, then Wk2 data etc.
What complicates this even more, is that the bars don't seem to sum the data in the series for me - I have to calculate my total and do a single "Add" call for each month (I was kind of hoping I didn't need to do this - again code solves this but its getting more complicated as I have to have a hashtable to collect up the values).
Finally what seems to make this even more difficult, is that I am finding (having resolved the above problems in my own code) - that if I then go to Add data for my second series - if I am missing "pendingSales" for a particular week - if I don't write a value out for that week the values for the next week (say week 3) will go into the week 2 position which didn't have any data.
Is this right? Do I need to work out my data dimensions and then rigidly stick to them (e.g. if its a 4 x 16 table of data, I have to ADD all 16 values for a particular series - otherwise I get off by X errors).
If this is the case - why do you need to specify a "label" for each data ADD - it seems superfluous - as it just seems to over-write the previous label?
I'm thinking that I'm doing something wrong - or missing some obvious solution so I would appreciate any tips or examples (in VB is fine - I will convert it).
Tim
Essentialy I want to have bars for: Jan Wk1, Jan Wk2, Jan Wk3, Jan Target, Feb Wk1 .... Feb Target etc.
For each bar I have 4 stacked values, Sales Complete, Sales In Progress, Sales Remaining, Target. The target should be zero for each of the weeks as there aren't any weekly targets but have a number for the "Month" Target bar. Hopefully you can visualise that.
Based on the avbove, my data is calculated in memory and I output to each of the series - the target series is Null for each of the WkX bars and has a positive value for the Monthly target bar (so you can easily see how close sales were to the targets) so I loop through each of my months and do (in pseudo code):
for each week targetSeries addNull (week name).
targetSeries add (month target), (month name + ' Target')
(I repeat the above for 4 months - e.g. a Quarter).
I wasn't expecting to have to write out the null values above but I found that if I didn't do this - my target values didn't line up for each bar.
Next I need to write out the actual sales - so I do something similar
for each week actualSalesSeries add week sales, week name
However this is where I hit the problem - I was kind of expecting to be able to write these values in any order, and if I provided the same label name then the items would just go into the correct columns. This doesn't seem to the be case - I seem to need to sort my data so that I process Wk1 data first, then Wk2 data etc.
What complicates this even more, is that the bars don't seem to sum the data in the series for me - I have to calculate my total and do a single "Add" call for each month (I was kind of hoping I didn't need to do this - again code solves this but its getting more complicated as I have to have a hashtable to collect up the values).
Finally what seems to make this even more difficult, is that I am finding (having resolved the above problems in my own code) - that if I then go to Add data for my second series - if I am missing "pendingSales" for a particular week - if I don't write a value out for that week the values for the next week (say week 3) will go into the week 2 position which didn't have any data.
Is this right? Do I need to work out my data dimensions and then rigidly stick to them (e.g. if its a 4 x 16 table of data, I have to ADD all 16 values for a particular series - otherwise I get off by X errors).
If this is the case - why do you need to specify a "label" for each data ADD - it seems superfluous - as it just seems to over-write the previous label?
I'm thinking that I'm doing something wrong - or missing some obvious solution so I would appreciate any tips or examples (in VB is fine - I will convert it).
Tim