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.


                <div id="content" class="content">
        <h1 id="title">United States GDP</h1>
        <p>Get more information at: <a href=""></a></p>
    <script src=""></script>
    <script type="text/javascript" src="index.js"></script>


                body {
    height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: #004c6d;

.content {
    background-color: white;
    padding: 10px;
    border-radius: 10px;
    box-shadow: 0 0 50px 10px black;

#title {
    text-align: center;

.bar {
    fill: #99d0f9;

.bar:hover {
    fill: white;

.tool-tip {
    height: 50px;

footer {
    margin-top: 50px;

a {
    color: white;
    text-decoration: none;


                let dataSet;
const height = 600;
const width = 1000;

const timeParser = (time) => {
    let year = time.getFullYear();
    let month = time.getMonth();
    let quarter;

    switch (month) {
        case 0:
        case 1:
        case 2:
            quarter = "Q1";
        case 3: 
        case 4:
        case 5:
            quarter = "Q2";
        case 6:
        case 7:
        case 8:
            quarter = "Q3";
        case 9:
        case 10:
        case 11:
            quarter = "Q4";

    return `${year} ${quarter}`

const gdpParser = (gdp) => {
    return `$ ${gdp} Billion`

    .then(response => response.json())
    .then(data => {

        //Raw DataSET as Link
        dataSet = data;

        //Timestmaps for Tooltips
        const timeIntervalls = => {

            let timeStampModified = new Date(data[0]);
            return timeStampModified;

        //all GDPs in arrays
        const gdp = => data[1]);

        //GDP max and min values
        const gdpMax = d3.max(gdp, (d) => d);
        const gdpMin = d3.min(gdp, (d) => d);

        //first and last year
        const yearMin = d3.min(timeIntervalls, (d) => d);
        const yearMax = d3.max(timeIntervalls, (d) => d);

        const xScale = d3.scaleTime().domain([yearMin, yearMax]).range([60, width - 60]);
        const yScale = d3.scaleLinear().domain([0, gdpMax]).range([height - 30, 30]);
        const linearScale = d3.scaleLinear().domain([0, gdpMax]).range([0, height - 60]);
        const xAxis = d3.axisBottom(xScale);
        const yAxis = d3.axisLeft(yScale);

        const svgBG ="#content")
                        .attr('width', width)
                        .attr('height', height)
                        .attr('class', "blue" )

            .attr("transform", "translate(0, " + (height - 30)+ ")")
            .attr("id", "x-axis")

            .attr("transform", "translate(" + 60 + ", 0)")
            .attr("id", "y-axis")
            .attr("data-date", function (d, i) {
            .attr("data-gdp", function(d, i) {
                return gdp[i]
            .attr("x", function(d, i) {
                return xScale(timeIntervalls[i]);
            .attr("y", function (d) {
                return height - 30 - linearScale(d);
            .attr("height", function(d) {
                return linearScale(d)
            .attr("width", 880 / 275)
            .attr("class", "bar")
            .attr("id", "tool-tip")
            .attr("class", "tool-tip")
            .text((d, i) => {
                return `Year: ${timeParser(timeIntervalls[i])}, GDP: ${gdpParser(d)}`

            .attr('transform', 'rotate(-90)')
            .attr('x', -300)
            .attr('y', 80)
            .text('Gross Domestic Product');

            .attr('x', 950)
            .attr('y', 600)