AnantLabs / googlechartsharp

Automatically exported from code.google.com/p/googlechartsharp
0 stars 0 forks source link

SimpleEncoding Problem (public static string Encode(ICollection<int[]> data)) #4

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi!

First thank you for this nice converions of Google Charts into C#!

I ve recognized a problem within the simpleencoding algorithm! I get wrong
images back.

You make the choosen encoding type dependet of the max value found in the
dataset. I would suggest to make it dependent of the width and height of
requested image. As for 300 x 250 61 values should be enough detailed.

i would suggest to take the orignial code snipped of the google developers
guide to do the simple encoding.

        public static string SimpleEncoding(int[] valueArray, int maxValue)
        {

            string simpleEncoding =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
            char[] arr_simpleEncoding = simpleEncoding.ToCharArray();

            string chartData = "";
            for (int i = 0; i < valueArray.Length; i++)
            {
                int currentValue = valueArray[i];
                if (currentValue >= 0)
                {
                    char curr_c =
arr_simpleEncoding[Convert.ToInt32(Math.Round((double)(simpleEncoding.Length -
1) * currentValue / maxValue))];
                    chartData += curr_c;
                }
                else
                {
                    chartData += "_";
                }
            }
            return chartData;
        }

hope this helps.

lg Alex

Original issue reported on code.google.com by off...@logicx.at on 2 Apr 2008 at 11:04