Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 您尚未回复的问题和答案。这在很大程度上违背了堆栈溢出礼仪,会让用户不愿意帮助您。例如,我在下面给出的答案@cyril在一个多月前给了你。@Mark Hi Mark!谢谢你的回答。我同意你的看法:我确实在没有回复的情况下发布了非常类似/重复的问题,这看起来确_Jquery_Json_Xml_D3.js_Nvd3.js - Fatal编程技术网

Jquery 您尚未回复的问题和答案。这在很大程度上违背了堆栈溢出礼仪,会让用户不愿意帮助您。例如,我在下面给出的答案@cyril在一个多月前给了你。@Mark Hi Mark!谢谢你的回答。我同意你的看法:我确实在没有回复的情况下发布了非常类似/重复的问题,这看起来确

Jquery 您尚未回复的问题和答案。这在很大程度上违背了堆栈溢出礼仪,会让用户不愿意帮助您。例如,我在下面给出的答案@cyril在一个多月前给了你。@Mark Hi Mark!谢谢你的回答。我同意你的看法:我确实在没有回复的情况下发布了非常类似/重复的问题,这看起来确,jquery,json,xml,d3.js,nvd3.js,Jquery,Json,Xml,D3.js,Nvd3.js,您尚未回复的问题和答案。这在很大程度上违背了堆栈溢出礼仪,会让用户不愿意帮助您。例如,我在下面给出的答案@cyril在一个多月前给了你。@Mark Hi Mark!谢谢你的回答。我同意你的看法:我确实在没有回复的情况下发布了非常类似/重复的问题,这看起来确实很糟糕。这些解决方案不起作用,因为我刚刚用谷歌的inspector发现了一些不相关的bug。尽管如此,我还是应该回答他们。我有时太专注了,以至于对别人变得不尊重。我为此道歉。 <script type="text/javascript"


您尚未回复的问题和答案。这在很大程度上违背了堆栈溢出礼仪,会让用户不愿意帮助您。例如,我在下面给出的答案@cyril在一个多月前给了你。@Mark Hi Mark!谢谢你的回答。我同意你的看法:我确实在没有回复的情况下发布了非常类似/重复的问题,这看起来确实很糟糕。这些解决方案不起作用,因为我刚刚用谷歌的inspector发现了一些不相关的bug。尽管如此,我还是应该回答他们。我有时太专注了,以至于对别人变得不尊重。我为此道歉。
<script type="text/javascript">
        $(document).ready(function(){
            $("#btGO").click(function(){
                var startDate = $("#startDate").val();
                var endDate = $("#endDate").val();

                $.ajax({
                    url: "dataWebService.asmx/getCasesForDateInterval",
                    method: "post",
                    data: {
                        startDate: startDate,
                        endDate: endDate
                    },
                    dataType: "json",
                    contentType: "application/json",
                    success: function (data) {
                        //This is where I attempt to pass my json data
                        d3.json(data, function (error, data) {
                            nv.addGraph(function () {
                                var chart = nv.models.stackedAreaChart()
                                              .x(function (d) { return d[0] })
                                              .y(function (d) { return d[1] })
                                              .clipEdge(true)
                                              .useInteractiveGuideline(true);

                                chart._options.controlOptions = ['Expanded', 'Stacked'];

                                chart.xAxis
                                    .showMaxMin(true)
                                    .tickFormat(function (d) { return d3.time.format('%x')(new Date(d)) });

                                chart.yAxis
                                    .tickFormat(d3.format(',.0f'));

                                d3.select('#chart svg')
                                  .datum(data)
                                    .transition().duration(500).call(chart);

                                nv.utils.windowResize(chart.update);

                                return chart;
                            });
                        });
                    }
                });

            });
        });
     </script>
    [WebMethod]
     public string getTotalForDateInterval(string startDate, string endDate)
    {
    string cs = ConfigurationManager.ConnectionStrings["vetDatabase_Wizard"].ConnectionString;
    List<keyValues> master = new List<keyValues>();

    using (SqlConnection con = new SqlConnection(cs))
    {
        SqlCommand cmd = new SqlCommand("sp_CountAndGroupByDate", con);
        cmd.CommandType = CommandType.StoredProcedure;

        //Linking SQL parameters with webmethod parameters
        SqlParameter param1 = new SqlParameter()
        {
            ParameterName = "@startDate",
            Value = startDate
        };

        SqlParameter param2 = new SqlParameter()
        {
            ParameterName = "@endDate",
            Value = endDate
        };

        cmd.Parameters.Add(param1);
        cmd.Parameters.Add(param2);
        con.Open();

        //Get time in milliseconds
        DateTime start = DateTime.ParseExact(startDate, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture);
        DateTime end = DateTime.ParseExact(endDate, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture);
        DateTime utime = DateTime.ParseExact("1970-01-01", "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture);

        long startMilliseconds = (long)((start - utime).TotalMilliseconds);
        long endMilliseconds = (long)((end - utime).TotalMilliseconds);
        const long oneDayInMilliseconds = 86400000;

        //Declare temp dictionary to store the lists
        Dictionary<string, List<long[]>> temp = new Dictionary<string, List<long[]>>();
        string[] buildings = { "SSB", "GEN", "LYM", "LUD", "GCC", "MAC", "MMB" };

        //Create building lists and initialize them with individual days and the default value of 0 
        foreach (string building in buildings){
            temp.Add(building, new List<long[]>());
            for (long j = startMilliseconds; j <= endMilliseconds; j = j + oneDayInMilliseconds){
                long[] timeTotal = { j, 0 };
                temp[building].Add(timeTotal);
            }
        }

        SqlDataReader rdr = cmd.ExecuteReader();
        while (rdr.Read())
        {

            //Remove time from dateTime2 and assign totals for appropriate date
            string s = (rdr["dateOpened"].ToString()).Substring(0, 10);
            DateTime dateOpened = DateTime.ParseExact(s, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture);
            long time = (long)((dateOpened - utime).TotalMilliseconds);
            long total = (long)Convert.ToInt32(rdr["total"]);

            string buildingName = rdr["building"].ToString();
            int index = temp[buildingName].FindIndex(r => r[0].Equals(time));
            temp[buildingName][index][1] = total;
        }
            //add all the keyValue objects to master list
            for (int i = 0; i < buildings.Length; i++)
            {
                keyValues kv = new keyValues();
                kv.key = buildings[i];
                kv.values = temp[kv.key];
                master.Add(kv);
            }

      }
    JavaScriptSerializer js = new JavaScriptSerializer();

    //Serialize list object into a JSON array and write in into the response stream
    string ss = js.Serialize(master);
    return ss;

}
 d3.json("dataWebService.asmx/getCasesForDateInterval", function (error, data) {
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public string getTotalForDateInterval(string startDate, string endDate)