|
A very strange problem |
Posted by Mark Manning on Sep-15-2010 07:24 |
|
Ok - it's me again! I know - "Ugh". Anyway....
I have written a program that generates five pie charts. I'm doing this in a loop which goes through some totals and it separates out those totals into what type of total it is. (So - it is a bunch of claim statuses which are then placed into some buckets [Accepted, Rejected, etc...]). That all seems to work without a problem.
What is happening is - if I do a KSORT() [in PHP] to ensure that the buckets are going to appear in the same order each time - the pie chart does weird things. The "weird" thing is that then all of the pie charts look the same. So it is like it is getting the same image over and over again.
NOW! To top everything off, to get this behavior, all I have to do is to include the KSORT function. So...
<Code to get the totals>
<Code to create the buckets>
ksort( $bucket );
<Code to generate the pie charts>
So if I comment out the KSORT - everything works but shows up in a random order because we do not know in what order the records appear. If I uncomment the KSORT function the charts all look the same. I've even dumped out all of the data each time. Here is some of it:
<!-- DEBUG : Called from /pi/edi/scripts/reports/dash_clmstspyr_rpt.php AT LINE #279 -->
<!-- DATA => ARRAY -->
<!-- . DATA(0) = 5 -->
<!-- . DATA(1) = 439 -->
<!-- . DATA(2) = 516 -->
<!-- . DATA(3) = 566564 -->
<!-- DEBUG : Called from /pi/edi/scripts/reports/dash_clmstspyr_rpt.php AT LINE #280 -->
<!-- LABELS => ARRAY -->
<!-- . LABELS(0) = Error -->
<!-- . LABELS(1) = Accepted -->
<!-- . LABELS(2) = Paid -->
<!-- . LABELS(3) = Processing -->
<!-- DEBUG : Called from /pi/edi/scripts/reports/dash_clmstspyr_rpt.php AT LINE #279 -->
So when the data is sorted, the labels are then alphabetical and the data does sort correctly. (I'm about to head home and the above [unfortunately] is after I turned off the dump code for the night.) This is most likely user error on my part but if I can get it to work correctly I'll post. If not, I'll try to reduce everything down to a really basic program to show what is happening.
So why post now? I'm just wondering if there is any kind of known error where ksort causes ChartDirector to muck up so I can steer clear of it if need be.
TIA! |
Re: A very strange problem |
Posted by Peter Kwan on Sep-15-2010 18:24 |
|
Hi Mark,
As far as I am aware, ChartDirector accepts inputs (the data in the method calls) and products outputs (the charts). ChartDirector cannot be affect by any code that does not input things to ChartDirector. So it cannot be affect by your ksort call.
There are several reasons why all the charts are the same. May be all the charts are created with the same data. Another possibility is that you code actually output only one chart image, and all the <IMG> tags are actually pointing to the same chart image.
For example, if your code are using session variables (using makeSession), but all session variables are of the same name (like "chart1"), then the second chart will overwrite the first chart, and the third chart will overwrite the second chart, and so on. So at the end, only the last chart survives, and there is really only one chart image from your code.
To diagnose the problem, one method we often use is to simply include the key information in the chart. For example, just after calling setData, you can call addTitle and include the first data value in the chart title. In this way, you can see the first data is consistent with the chart. In the chart title, you may also include a random number (or a serial number), so that you can verify if you are seeing different charts (the charts should have different serial number) or the same chart. You can also use BaseChart.makeChart to save a copy of the chart image on the hard disk (make sure you use unique names for the different charts, and save to a directory that is readable and writable by the web server anonymous user). In this way, you can get an audit trial of the outputs and verify if the browser is actually seeing what the server produces.
Hope this can help.
Regards
Peter Kwan |
Re: A very strange problem |
Posted by Mark Manning on Sep-16-2010 03:51 |
|
Ok - here is a good example of what I am talking about. These two charts have FOUR labels at the bottom but FIVE segments to them.
It has taken me almost all day to finally verify every variable to make sure it wasn't something that I was doing. I've mailed Peter several times with the results and I am sure he will respond as soon as he's looked everything over. So this posting is just to let everyone know that most likely there is some kind of a caching problem going on here. (And I actually still have some hair left! :-P )
Also note that all of the percentages are the same but the labels change. So I have no idea where it is getting the fifth label from and the two companies have similar information but not the same. So the percentages should be changing somewhat each time.
|
Re: A very strange problem |
Posted by Peter Kwan on Sep-16-2010 16:23 |
|
Hi Mark,
I think the legend does have 5 entries, but one of the legend wraps to the second line. May be your code puts the legend too near to the bottom of the chart image, so the second line flows outside the chart image.
Just in case someone is following this thread, so I would briefly explain the findings from the email. By looking at the charts before ksort and after ksort, it seems the data used to plot the charts are in fact the same, even if ksort is not used. So it is normal the two charts are the same after ksort.
Regards
Peter Kwan |
Re: A very strange problem |
Posted by Mark Manning on Sep-16-2010 23:27 |
|
As I just e-mailed:
Er.....no.
The original labels that went across the bottom were "Accepted", "Paid", "Error", "Completed", and "Processing". (I think I put "Pending" in my e-mail. It is one or the other and I'll have to check.) In any event, "Accepted" = 8 characters, "Paid" = 4 characters, "Error" = 5 characters ("Pending" is 7 characters), "Completed" is 9 characters, and "Processing" is 10 characters. Totaled they come up to 8 + 5(7) + 9 + 10 = 32(34) characters PLUS the percentages.
The numeric labels are only between zero(0) and one-hundred(100) so a maximum of 3 characters each. 3* 5 = 15 characters.
None of the labels wrapped when I was using the words. I switched to using numbers only so I could randomize what label appeared where.
Since, when the alphabetic labels were used, nothing wrapped, then there must be a problem with ChartDirector. Either A)It dislikes numeric labels and tries to hide them, or B)It has a thing against shorter label lengths. At least, that is all I can think of as the possible reason for it to suddenly start wrapping shorter lines.
Or maybe there is some other problem going on here?
Let me know!
Here is an example of what I mean. Note that all of the labels are showing and there are five of them. Same program. Same graph. Just turned off the numeric labels and turned on the alphabetic ones.
|
Re: A very strange problem |
Posted by Mark Manning on Sep-16-2010 23:31 |
|
OK! I have to backup in what I said.
I did not notice that the labels said "label_###" I thought I had only made it say "###"!
So you might be right Peter! Shocking - I know.
Let me check it out. However, the actual graph is much wider than what the labels are using. Still - let me check this again. I'll post as soon afterwards as possible. |
Re: A very strange problem |
Posted by Mark Manning on Sep-17-2010 00:26 |
|
You were right - when the "label_###" are used - they wrap. My trouble is - I had made so many test images that I'd forgotten I'd put the "label_" part. I remember that I thought it was kind-of hard to tell where the label ended and the percentage began on the chart itself and that was why I had switched it. But I thought I had switched it back. My bad! :-/
Ok! I just ran the numbers and did my own percentages and guess what? Call me stupid and give me a lashing. I've never seen this happen before with these companies.
Commercial Medicare Medicaid BCBS Champus
1)commercial :
2) total = 734849 -> 100%
2) accepted = 436 -> 0.06%
2) complete = 9 -> 0%
2) error = 34 -> 0%
2) paid = 690 -> 0.09%
2) processing = 733680 -> 99.84%
1)medicare :
2) total = 60927 -> 100%
2) accepted = 30084 -> 49.38%
2) complete = 207 -> 0.34%
2) error = 2346 -> 3.85%
2) paid = 15870 -> 26.05%
2) processing = 12420 -> 20.39%
1)medicaid :
2) total = 86534 -> 100%
2) accepted = 42728 -> 49.38%
2) complete = 294 -> 0.34%
2) error = 3332 -> 3.85%
2) paid = 22540 -> 26.05%
2) processing = 17640 -> 20.39%
1)bcbs :
2) total = 100662 -> 100%
2) accepted = 49704 -> 49.38%
2) complete = 342 -> 0.34%
2) error = 3876 -> 3.85%
2) paid = 26220 -> 26.05%
2) processing = 20520 -> 20.39%
1)champus :
2) total = 13245 -> 100%
2) accepted = 6540 -> 49.38%
2) complete = 45 -> 0.34%
2) error = 510 -> 3.85%
2) paid = 3450 -> 26.05%
2) processing = 2700 -> 20.39%
Different numbers, different counts, the same exact percentages for all of them. There's nothing wrong with ChartDirector. It's just really weird numbers that happen to come out to the exact same values each time.
Weird. :-/ |
|