コード例 #1
0
ファイル: BaseGVI.cs プロジェクト: hemrika/SharePresence
        /// <summary>
        /// Trying to use this option from here out!
        /// </summary>
        /// <param name="PageControl"></param>
        /// <param name="dt"></param>
        /// <param name="CHARTTYPE"></param>
        internal void RegisterGVIScriptsEx(BaseWebControl PageControl, DataTable dt, GOOGLECHART CHARTTYPE)
        {
            if (!REGISTER_GOOGLE_API_JS)
            {
                PageControl.Page.ClientScript.RegisterStartupScript(this.GetType(), "REGISTER_GOOGLE_API_JS", @"<script type='text/javascript' src='http://www.google.com/jsapi'></script>");
                REGISTER_GOOGLE_API_JS = true;
            }

            string events  = RenderGVIEvents(PageControl);
            string options = RenderGVIConfigOptions(PageControl);

            if ((PageControl.GviOptionsOverride != null) && (!string.IsNullOrEmpty(PageControl.GviOptionsOverride.ToString())))
            {
                // the override switch is in play ... use the json struct here to override the manually set items...
                options = PageControl.GviOptionsOverride.ToString();
            }
            // base.OnPreRender(e);
            string optionsJscode = string.Format(jscode2, PageControl.ClientID, options, dic[CHARTTYPE].FirstOrDefault(), dic[CHARTTYPE].LastOrDefault(), events);
            string build         = string.Format("v{0}.{1}.{2}.{3}",
                                                 System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Major,
                                                 System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.MajorRevision,
                                                 System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Minor,
                                                 System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.MinorRevision);

            optionsJscode = optionsJscode.Replace("{ver}", build);

            PageControl.Page.ClientScript.RegisterStartupScript(this.GetType(), "function_" + PageControl.ClientID, optionsJscode, true);

            if (this.dt == null)
            {
                throw new Exception(string.Format("Unable to create visualization '{0}' with an empty DataTable ", this.GetType().FullName));
            }

            //Bortosky.Google.Visualization.GoogleDataTable gdt = new Bortosky.Google.Visualization.GoogleDataTable(dt);
            string datatableoutput = TransformDataTable.ToGoogleDataTable(dt);

            PageControl.Page.ClientScript.RegisterStartupScript(this.GetType(), "vis_" + PageControl.ClientID, string.Format("var data_{0} = function() {{ {1} }}", PageControl.ClientID, datatableoutput), true);
        }
コード例 #2
0
        /// <summary>
        /// Trying to use this option from here out!
        /// </summary>
        /// <param name="PageControl"></param>
        /// <param name="dt"></param>
        /// <param name="CHARTTYPE"></param>
        internal void RegisterGVIScriptsEx(BaseWebControl PageControl, DataTable dt, GOOGLECHART CHARTTYPE)
        {
            string JAVASCRIPT = jscode3;

            //if (CHARTTYPE == GOOGLECHART.CHAP_TIMELINE)
            //    JAVASCRIPT = jschap;

            string options,formatter = string.Empty;
            string imagereplace = string.Empty;
            List<string> events = RenderGVIEvents(PageControl);

            if (PageControl is IGoogleTableFormatterControl)
                formatter = RenderFormatter((IGoogleTableFormatterControl)PageControl);

            if (this.BindingDataTable != null)
            {
                ((EventHandler)this.BindingDataTable)(this, EventArgs.Empty);
            }

            JAVASCRIPT = JAVASCRIPT.Replace("{formatter}", formatter);
            if (!string.IsNullOrEmpty(PageControl.QueryString) && PageControl.QueryString.StartsWith("~"))
            {
                PageControl.QueryString = PageControl.Page.ResolveUrl(PageControl.QueryString);
                JAVASCRIPT = JAVASCRIPT.Replace("{QueryString}", PageControl.QueryString);
            }
            else
            {
                JAVASCRIPT = JAVASCRIPT.Replace("{QueryString}", PageControl.QueryString);
            }

            imagereplace = RenderSetImage(PageControl);
            JAVASCRIPT = JAVASCRIPT.Replace("{SETIMAGEFOR}", imagereplace);

            // Check if manual override for Chart option is in effect
            if ((PageControl.GviOptionsOverride != null) && (!string.IsNullOrEmpty(PageControl.GviOptionsOverride.ToString())))
                options = PageControl.GviOptionsOverride.ToString();
            else
                options = RenderGVIConfigOptions(PageControl);

            // the name of the control being bound and over-written
            string ctlid = PageControl.ClientID;
            if (!string.IsNullOrEmpty(PageControl.OverrideElementId))
                ctlid = PageControl.OverrideElementId;

            // interpolate the options into the canned Javascript
            string optionsJscode = string.Format(JAVASCRIPT,
                ctlid,
                options,
                dic[CHARTTYPE].FirstOrDefault(),
                dic[CHARTTYPE].LastOrDefault(),
                string.Join("\n",events.ToArray()),
                dic[CHARTTYPE].FirstOrDefault().UpperCaseFirst()
            );

            // add version information onto each ChartJavascript
            string build = string.Format("v{0}.{1}.{2}.{3}",
                System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Major,
                System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.MajorRevision,
                System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Minor,
                System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.MinorRevision);
            optionsJscode = optionsJscode.Replace("{ver}", build);

            // load the datatable...
            if (dt == null)
                throw new Exception(string.Format("Unable to create visualization '{0}' with an empty DataTable ", this.GetType().FullName));

            Bortosky.Google.Visualization.GoogleDataTable gdt = new Bortosky.Google.Visualization.GoogleDataTable(dt);
            optionsJscode = optionsJscode.Replace("__DATATABLE__", PageControl.PostProcessData( gdt.GetJson()));

            /*
             * This allows you to manipulate the data
             *  var formatter = new google.visualization.NumberFormat({prefix: '$'});
             *  formatter.format(data, 1); // Apply formatter to second column
             */
            if (!string.IsNullOrEmpty(PageControl.GviFormatterHook))
                optionsJscode = optionsJscode.Replace("/*FORMATTERS*/", string.Format("{0}(chart, data);", PageControl.GviFormatterHook));

            PageControl.Page.ClientScript.RegisterStartupScript(this.GetType(), "function_" + ctlid, optionsJscode, true);

            //RenderSetImage(PageControl);
            //string datatableoutput = TransformDataTable.ToGoogleDataTable(dt);
            //PageControl.Page.ClientScript.RegisterStartupScript(this.GetType(), "vis_" + ctlid, string.Format("var data_{0} = function() {{ {1} }}", ctlid, datatableoutput), true);
        }
コード例 #3
0
        /// <summary>
        /// Trying to use this option from here out!
        /// </summary>
        /// <param name="PageControl"></param>
        /// <param name="dt"></param>
        /// <param name="CHARTTYPE"></param>
        internal void RegisterGVIScriptsEx(BaseWebControl PageControl, DataTable dt, GOOGLECHART CHARTTYPE)
        {
            string JAVASCRIPT = jscode3;

            //if (CHARTTYPE == GOOGLECHART.CHAP_TIMELINE)
            //    JAVASCRIPT = jschap;

            string        options, formatter = string.Empty;
            string        imagereplace = string.Empty;
            List <string> events       = RenderGVIEvents(PageControl);


            if (PageControl is IGoogleTableFormatterControl)
            {
                formatter = RenderFormatter((IGoogleTableFormatterControl)PageControl);
            }


            if (this.BindingDataTable != null)
            {
                ((EventHandler)this.BindingDataTable)(this, EventArgs.Empty);
            }


            JAVASCRIPT = JAVASCRIPT.Replace("{formatter}", formatter);
            if (!string.IsNullOrEmpty(PageControl.QueryString) && PageControl.QueryString.StartsWith("~"))
            {
                PageControl.QueryString = PageControl.Page.ResolveUrl(PageControl.QueryString);
                JAVASCRIPT = JAVASCRIPT.Replace("{QueryString}", PageControl.QueryString);
            }
            else
            {
                JAVASCRIPT = JAVASCRIPT.Replace("{QueryString}", PageControl.QueryString);
            }


            imagereplace = RenderSetImage(PageControl);
            JAVASCRIPT   = JAVASCRIPT.Replace("{SETIMAGEFOR}", imagereplace);



            // Check if manual override for Chart option is in effect
            if ((PageControl.GviOptionsOverride != null) && (!string.IsNullOrEmpty(PageControl.GviOptionsOverride.ToString())))
            {
                options = PageControl.GviOptionsOverride.ToString();
            }
            else
            {
                options = RenderGVIConfigOptions(PageControl);
            }


            // the name of the control being bound and over-written
            string ctlid = PageControl.ClientID;

            if (!string.IsNullOrEmpty(PageControl.OverrideElementId))
            {
                ctlid = PageControl.OverrideElementId;
            }

            // interpolate the options into the canned Javascript
            string optionsJscode = string.Format(JAVASCRIPT,
                                                 ctlid,
                                                 options,
                                                 dic[CHARTTYPE].FirstOrDefault(),
                                                 dic[CHARTTYPE].LastOrDefault(),
                                                 string.Join("\n", events.ToArray()),
                                                 dic[CHARTTYPE].FirstOrDefault().UpperCaseFirst()
                                                 );

            // add version information onto each ChartJavascript
            string build = string.Format("v{0}.{1}.{2}.{3}",
                                         System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Major,
                                         System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.MajorRevision,
                                         System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Minor,
                                         System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.MinorRevision);

            optionsJscode = optionsJscode.Replace("{ver}", build);


            // load the datatable...
            if (dt == null)
            {
                throw new Exception(string.Format("Unable to create visualization '{0}' with an empty DataTable ", this.GetType().FullName));
            }


            Bortosky.Google.Visualization.GoogleDataTable gdt = new Bortosky.Google.Visualization.GoogleDataTable(dt);
            optionsJscode = optionsJscode.Replace("__DATATABLE__", PageControl.PostProcessData(gdt.GetJson()));



            /*
             * This allows you to manipulate the data
             *  var formatter = new google.visualization.NumberFormat({prefix: '$'});
             *  formatter.format(data, 1); // Apply formatter to second column
             */
            if (!string.IsNullOrEmpty(PageControl.GviFormatterHook))
            {
                optionsJscode = optionsJscode.Replace("/*FORMATTERS*/", string.Format("{0}(chart, data);", PageControl.GviFormatterHook));
            }

            PageControl.Page.ClientScript.RegisterStartupScript(this.GetType(), "function_" + ctlid, optionsJscode, true);

            //RenderSetImage(PageControl);
            //string datatableoutput = TransformDataTable.ToGoogleDataTable(dt);
            //PageControl.Page.ClientScript.RegisterStartupScript(this.GetType(), "vis_" + ctlid, string.Format("var data_{0} = function() {{ {1} }}", ctlid, datatableoutput), true);
        }