久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

使用關聯數組的 D3 日歷視圖

D3 Calendar View using Associative Array(使用關聯數組的 D3 日歷視圖)
本文介紹了使用關聯數組的 D3 日歷視圖的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我想創建一個日歷視圖,如下例所示:

編輯 3:

我已經解決了第 1 步和第 2 步,這里是 jsfiddle 鏈接:http://jsfiddle.net/makoto/ARy8d/9/

現在試圖找到一種解決方法來在同一個單元格中添加多值

例如,如果我在數組中有 2 個值具有相同的日期,我想添加并在右側單元格中查看它們.但是代碼現在的作用是,如果有 2 個值具有相同的日期值,則最后一個會覆蓋第一個.

任何幫助都可以,在此先感謝.

解決方案

對于那些與我曾經遇到過類似問題的人來說,這里是針對 1 號和 2 號的解決方案.希望這會有所幫助.

數組如下所示:BigWordsDates2 = {"#Tahrir":[["2012-10-12",20],["2012-10-13",1],["2012-10-19",15]],"#Egypt":[["2012-10-01",3],["2012-10-03",2],["2012-10-04",3],["2012-10-07",1],["2012-10-10",1],["2012-10-13",2],["2012-10-14",1],["2012-10-15",1],["2012-10-16",1],["2012-10-17",4],["2012-10-19",5]]};

像這樣保存你的目標數組值的值:var tahrir = BigWordsDates2['#Tahrir']

然后用它覆蓋 CSV 數據.您可以在下面的 jsfiddle 中找到帶有解決方案的示例.

http://jsfiddle.net/makoto/ARy8d/7/

I want to create a Calendar View Like this example: http://bl.ocks.org/4063318:

Actually i am trying to modify it.

I have an associative array like this: #AdminCourt[["2012-10-02", 2], ["2012-10-09", 2], ["2012-10-16", 1]] #ConstituentAssembly[["2012-10-02", 2], ["2012-10-09", 2], ["2012-10-12", 2], ["2012-10-16", 2]]

I tried filling the calendar like this:

BigWordsDates2.map(function(d) {
              return {
                 date: d[0],
                 close: d[1]
              };
              var data = d3.nest()
    .key(function(d) { return d.Date; })
    .rollup(function(d) { return (d.Close - 0); });

  rect.filter(function(d) { return d in data; })
      .attr("class", function(d) { return "day " + color(data[d]); })
    .select("title")
      .text(function(d) { return d + ": " + percent(data[d]); });
      });

I know i am not looping through the array and i dont know how i tried for each but it seems that i dont get it correctly.

Here are the stuff that i need ur help with :)

  1. Loop through the array.( I know how to loop on it but i dont know if there is a way through the D3 class )
  2. How to Make each cell clickable.
  3. if i can add MultiValues in a cell ( Probably the keys of the array it depends on the date values).
  4. How to make the calendar Dynamic Not Set to a certain Range.

Here is the script code i have:

var w = 760,
    h = 530;
    var cloudwidth = 700, cloudheight=500;
    var FunctionCount=0;
    var BigWord;
    var SmallWord;
    var tweets =  <?php echo json_encode($Row_Words_Repeated_Relation); ?>;
    //var tweets = JSON.parse(TweetsAnalized);
    var tweetscounts = JSON.parse('<?php echo $Array_OfCounters_to_json ?>');
    var BigWordsDates2 = <?php echo json_encode($Array_OfDates); ?>;
    //var BigWordsDates2 = JSON.parse(BigWordsDates);
    var OriginalTweets = JSON.parse('<?php echo mysql_real_escape_string($OriginalTweets_to_json) ?>');

    var width = 960,
    height = 136,
    cellSize = 17; // cell size

var day = d3.time.format("%w"),
    week = d3.time.format("%U"),
    percent = d3.format(".1%"),
    format = d3.time.format("%Y-%m-%d");

var color = d3.scale.quantize()
    .domain([-.05, .05])
    .range(d3.range(11).map(function(d) { return "q" + d + "-11"; }));

var svg = d3.select("body").selectAll("svg")
    .data(d3.range(2005, 2015))
  .enter().append("svg")
    .attr("width", width)
    .attr("height", height)
    .attr("class", "RdYlGn")
  .append("g")
    .attr("transform", "translate(" + ((width - cellSize * 53) / 2) + "," + (height - cellSize * 7 - 1) + ")");

svg.append("text")
    .attr("transform", "translate(-6," + cellSize * 3.5 + ")rotate(-90)")
    .style("text-anchor", "middle")
    .text(function(d) { return d; });

var rect = svg.selectAll(".day")
    .data(function(d) { return d3.time.days(new Date(d, 0, 1), new Date(d + 1, 0, 1)); })
  .enter().append("rect")
    .attr("class", "day")
    .attr("width", cellSize)
    .attr("height", cellSize)
    .attr("x", function(d) { return week(d) * cellSize; })
    .attr("y", function(d) { return day(d) * cellSize; })
    .datum(format);

rect.append("title")
    .text(function(d) { return d; });

svg.selectAll(".month")
    .data(function(d) { return d3.time.months(new Date(d, 0, 1), new Date(d + 1, 0, 1)); })
  .enter().append("path")
    .attr("class", "month")
    .attr("d", monthPath);

/*d3.csv("dji.csv", function(error, csv) {
  var data = d3.nest()
    .key(function(d) { return d.Date; })
    .rollup(function(d) { return (d[0].Close - d[0].Open) / d[0].Open; })
    .map(csv);

  rect.filter(function(d) { return d in data; })
      .attr("class", function(d) { return "day " + color(data[d]); })
    .select("title")
      .text(function(d) { return d + ": " + percent(data[d]); });
});*/
BigWordsDates2["#Tahrir"].map(function(d) {
              return {
                 date: d[0],
                 close: d[1]
              };
              var data = d3.nest()
    .key(function(d) { return d.Date; })
    .rollup(function(d) { return (d.Close - 0); });

  rect.filter(function(d) { return d in data; })
      .attr("class", function(d) { return "day " + color(data[d]); })
    .select("title")
      .text(function(d) { return d + ": " + percent(data[d]); });
      });




function monthPath(t0) {
  var t1 = new Date(t0.getFullYear(), t0.getMonth() + 1, 0),
      d0 = +day(t0), w0 = +week(t0),
      d1 = +day(t1), w1 = +week(t1);
  return "M" + (w0 + 1) * cellSize + "," + d0 * cellSize
      + "H" + w0 * cellSize + "V" + 7 * cellSize
      + "H" + w1 * cellSize + "V" + (d1 + 1) * cellSize
      + "H" + (w1 + 1) * cellSize + "V" + 0
      + "H" + (w0 + 1) * cellSize + "Z";
}

d3.select(self.frameElement).style("height", "2910px");

Thanks In Advance and i would really appreciate the help.

EDIT 1:

I tried to work on something like that:

var data1 = d3.entries(BigWordsDates2).forEach(function(d) {
for each (var i in BigWordsDates2[d.key]){
return {
       Date: BigWordsDates2[d.key][i][0],
       Close: BigWordsDates2[d.key][i][1]
    };
};
var data = d3.nest()
.key(function(data1) { return d.Date; })
.rollup(function(data1) { return (d.Close - 0); });

Edit 2: i worked around what was above a bit and this is all i can think of would really need Help, no idea why the values aint appended in the calendar.

var width = 960,
    height = 136,
    cellSize = 17; // cell size

var day = d3.time.format("%w"),
    week = d3.time.format("%U"),
    percent = d3.format(".1%"),
    format = d3.time.format("%Y-%m-%d");

var color = d3.scale.quantize()
    .domain([-.05, .05])
    .range(d3.range(11).map(function(d) { return "q" + d + "-11"; }));

var svg = d3.select("body").selectAll("svg")
    .data(d3.range(2005, 2015))
  .enter().append("svg")
    .attr("width", width)
    .attr("height", height)
    .attr("class", "RdYlGn")
  .append("g")
    .attr("transform", "translate(" + ((width - cellSize * 53) / 2) + "," + (height - cellSize * 7 - 1) + ")");

svg.append("text")
    .attr("transform", "translate(-6," + cellSize * 3.5 + ")rotate(-90)")
    .style("text-anchor", "middle")
    .text(function(d) { return d; });

var rect = svg.selectAll(".day")
    .data(function(d) { return d3.time.days(new Date(d, 0, 1), new Date(d + 1, 0, 1)); })
  .enter().append("rect")
    .attr("class", "day")
    .attr("width", cellSize)
    .attr("height", cellSize)
    .attr("x", function(d) { return week(d) * cellSize; })
    .attr("y", function(d) { return day(d) * cellSize; })
    .datum(format);

rect.append("title")
    .text(function(d) { return d; });

svg.selectAll(".month")
    .data(function(d) { return d3.time.months(new Date(d, 0, 1), new Date(d + 1, 0, 1)); })
  .enter().append("path")
    .attr("class", "month")
    .attr("d", monthPath);

/*d3.csv("dji.csv", function(error, csv) {
  var data = d3.nest()
    .key(function(d) { return d.Date; })
    .rollup(function(d) { return (d[0].Close - d[0].Open) / d[0].Open; })
    .map(csv);

  rect.filter(function(d) { return d in data; })
      .attr("class", function(d) { return "day " + color(data[d]); })
    .select("title")
      .text(function(d) { return d + ": " + percent(data[d]); });
});*/


    d3.entries(BigWordsDates2).map(function(d) {
        for each (var i in BigWordsDates2[d.key]){
            /*var count =i;
              return {
                 Date: i[0],
                 Close: i[1]
              };*/                                               
      rect.filter(function(i) { return i in BigWordsDates2; })
          .attr("class", function(i) { return "day " + color(i[0]); })
        .select("title")
          .text(function(i) { return d.key + ": " + percent(i[1]); });

       };
  });



function monthPath(t0) {
  var t1 = new Date(t0.getFullYear(), t0.getMonth() + 1, 0),
      d0 = +day(t0), w0 = +week(t0),
      d1 = +day(t1), w1 = +week(t1);
  return "M" + (w0 + 1) * cellSize + "," + d0 * cellSize
      + "H" + w0 * cellSize + "V" + 7 * cellSize
      + "H" + w1 * cellSize + "V" + (d1 + 1) * cellSize
      + "H" + (w1 + 1) * cellSize + "V" + 0
      + "H" + (w0 + 1) * cellSize + "Z";
}

d3.select(self.frameElement).style("height", "2910px");

I think am close. any help would be appreciated.

I made a jsfiddle template: http://jsfiddle.net/ARy8d/1/

EDIT 3:

i got Steps 1 and 2 are solved and here is the jsfiddle link: http://jsfiddle.net/makoto/ARy8d/9/

Now trying to find a workaround to add multivalues in same cell

For Example if i have 2 values in array that has the same date i want to add and view them in the right cell. however what the code does right now that if there are 2 values with the same date value the last one overwrites the first one.

Any help will do, thanks in advance.

解決方案

Here Is The Solution For Number 1 and 2 for those who has the problem similar to the ones i used to have. hope that will helpful.

The array Looks Like That: BigWordsDates2 = {"#Tahrir":[["2012-10-12",20],["2012-10-13",1],["2012-10-19",15]],"#Egypt":[["2012-10-01",3],["2012-10-03",2],["2012-10-04",3],["2012-10-07",1],["2012-10-10",1],["2012-10-13",2],["2012-10-14",1],["2012-10-15",1],["2012-10-16",1],["2012-10-17",4],["2012-10-19",5]]};

Save the Value that Your Targeted array Values you want like that: var tahrir = BigWordsDates2['#Tahrir']

and then overwrite the CSV Data with it. You can Find The example with solution in the jsfiddle below.

http://jsfiddle.net/makoto/ARy8d/7/

這篇關于使用關聯數組的 D3 日歷視圖的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

jQuery/JavaScript Library for avatar creation?(用于創建頭像的 jQuery/JavaScript 庫?)
How to do following mask input problem?(如何做以下掩碼輸入問題?)
Issues Setting Value/Label Using DropKick Javascript(使用 DropKick Javascript 設置值/標簽的問題)
how to unit-test private methods in jquery plugins?(如何對 jquery 插件中的私有方法進行單元測試?)
stellar.js - configuring offsets / aligning elements for a vertical scrolling website?(stellar.js - 為垂直滾動網站配置偏移量/對齊元素?)
jQuery masked input plugin. select all content when textbox receives focus(jQuery 屏蔽輸入插件.當文本框獲得焦點時選擇所有內容)
主站蜘蛛池模板: 国产精品久久久久久久久久妞妞 | 开操网| 国产美女在线精品免费 | 亚洲在线 | 一区二区三区小视频 | 亚洲福利在线观看 | www.久久| 国产欧美在线一区 | 国产精品日产欧美久久久久 | 国产精品毛片无码 | 玖玖精品 | 天天操天天摸天天爽 | 九九久久国产精品 | 极品电影院 | 一区二区三区四区免费视频 | 亚洲精品久久久久国产 | 精品欧美一区免费观看α√ | 欧美日韩中文字幕在线播放 | 九九热在线视频 | 9999精品视频 | 国产精品久久久久久av公交车 | 久久国产精品首页 | 91高清在线观看 | 国产一区二区电影 | 人干人人| 亚洲精品成人 | 欧美在线国产精品 | 国产色婷婷精品综合在线手机播放 | 自拍偷拍亚洲一区 | 色综合色综合色综合 | 国产一区二区三区四区 | 国产一区二区在线播放 | 精品国产高清一区二区三区 | 91色啪 | 亚洲性视频网站 | 欧美激情精品久久久久久免费 | 亚洲在线免费观看 | 四虎影院一区二区 | 久久不射网 | 欧美一区二区大片 | 中文字幕人成乱码在线观看 |