Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9018881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:38:35+00:00 2026-06-16T04:38:35+00:00

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

  • 0

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

enter image description here

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T04:38:36+00:00Added an answer on June 16, 2026 at 4:38 am

    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/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a view like the calendar in the image below, but
Friends! I want to create a simple schedule event calendar like this one Question:
Well I don't actually want to make a calendar but I need a view
I have a list view that looks like this and that's its code ..
I want to create a calendar in my application that external users can view.
Hello I want to create month-view calendar for android with clickable days. What kind
I want to create an event calendar application similar to the site http://events.stanford.edu/ using
I want to create a calendar system, it is something like Google calendar allow
This is a simple question. I want to create an inline calendar that does
I want to create something like this |Button| item 1 item 2 item 3

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.