Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


<!DOCTYPE html>
  <meta charset="UTF-8">
  <meta name="description" content="Quote Machine">
  <meta name="keywords" content="HTML,CSS,XML,JavaScript,JQuery,Bootstrap,Ajax">
  <meta name="author" content="Cesar Gomez">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <link href=",600,700" rel="stylesheet"><script src=""></script>

  <div class="text-center">
     <h1 id="title">DATA CHART</h1>
  <div class="row">
    <div class="col">
            <div id="graph"> </div>
                            <div  class="freeIcon text-center">
        <i class="fab fa-free-code-camp"></i>

    <div class="col">
      <div class="text-center" id="userTitle">
        <h3>User Stories to Complete</h3>
        <li>My chart should have a title with a corresponding id="title"</li>
        <li>My chart should have a g element x-axis with a corresponding id="x-axis".</li>
        <li>My chart should have a g element y-axis with a corresponding id="y-axis"</li>
        <li>Both axes should contain multiple tick labels, each with the corresponding class="tick"</li>
        <li>My chart should have a rect element for each data point with a corresponding class="bar" displaying the data</li>
        <li> Each bar should have the properties data-date and data-gdp containing date and GDP values</li>
        <li>The bar elements' data-date properties should match the order of the provided data</li>
        <li>The bar elements' data-gdp properties should match the order of the provided data</li>
        <li>Each bar element's height should accurately represent the data's corresponding GDP</li>
         <li>The data-date attribute and its corresponding bar element should align with the corresponding value on the x-axis</li>
         <li>The data-gdp attribute and its corresponding bar element should align with the corresponding value on the y-axis</li>
         <li>I can mouse over an area and see a tooltip with a corresponding id="tooltip" which displays more information about the area</li>
        <li>My tooltip should have a data-date property that corresponds to the data-date of the active area</li>





  background-color: #2f2fa2;

#graph {
  margin-top: 40px;

  color: #fff;
  border-bottom: 5px;

.bar {
  fill: #f64c72;



div.tooltip {		
    text-align: center;			
    width: 60px;					
    height: 48px;					
    padding: 2px;				
    font: 12px sans-serif;		
    background: lightsteelblue;	
    border: 0px;		
    border-radius: 8px;			
    pointer-events: none;
ul {
  color: #fff;

  padding: 5px;

  font-size: 95px;
  color: #fff;

  margin-bottom: 10px;
  color: #99738e;




let value = [];
let dates = []

const width = 700;
const height = 530;

d3.json("").then((data) => {
  let datas =;
    dates.push(new Date (setData[0]))
    // value.splice(55, value.length)

const svg ="#graph")
                .attr("height", height);

  const sameDate = d3.timeFormat("%Y-%m-%d")	

const xScale = d3.scaleTime()
                  .domain([d3.min(dates), d3.max(dates)])
                  .range([0 , width - 80]);

const x_axis = d3.axisBottom()

const yAxis = d3.scaleLinear()
                .domain([0, d3.max(value)])
                .range([height , 0])

const y_axis = d3.axisLeft()

const scaleGross = d3.scaleLinear()
                     .domain([0, d3.max(value)])
                     .range([0, height])

const gdp ={
  return scaleGross(item)

let xAxisTranslate = height - 30;
const yAxisTranslate = 0 - 30;
            .attr("transform", "translate(50, " + xAxisTranslate  +")")
         .attr("transform","translate(50,"+ yAxisTranslate +")")

let div ="body").append("div")	
            .attr("class", "tooltip")
            .attr("id", "tooltip")
             .style("opacity", 0);
         .attr("data-date", function(d,i) {
            return datas[i][0]
         .attr("data-gdp", function(d,i) {
            return datas[i][1]
         .attr('x', function(d, i) {
           return xScale(dates[i]);

         .attr("y", (d,i) =>{
          return height - d 
          .classed("bar", true)
          .on("mouseover", function(d,i) {
              let coordinates = d3.mouse(this)
              const formYear = d3.timeFormat("%b %Y")
             .classed("active", true)

                .style("opacity", .9)
                div.attr("data-date", datas[i][0])                 
                .html("Date " + "</br>" + formYear(dates[i]) + "</br>" + "$" +"data-gdp"))	
                .style("left", event.clientX + "px")
                .style("top", (coordinates[1]) + "px")

          .on("mouseout", function(d) {
              .classed("active", false)                   
                .style("opacity", 0);
         .attr("width", width/275)
         .attr("height", (d) => {
           return d;