Pen Settings

HTML

CSS

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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

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.

HTML

              
                <head>
  <script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
  <link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
  <link href="https://fonts.googleapis.com/css?family=Nunito+Sans" rel="stylesheet">
</head>

<body>
  <div class="background">
  <div id="area">
    <div id="graph"></div>
    <div id="link1" class="link"><a target="_blank" href="https://cdpn.io/ideaapps/debug/mvGZZX" rel="noreferrer"><span>Viz také dopady na vzdělanost</span></a></div>
    <div id="logo"><img src="https://raw.githubusercontent.com/threndash/logo/master/idea-white.png" /></div>
    <div id="link2" class="link"><a target="_blank" href="https://idea.cerge-ei.cz/files/IDEA_Studie_05_2019_Dopady_kvality_prace_ucitelu/IDEA_Studie_05_2019_Dopady_kvality_prace_ucitelu.html"><span>Podrobnosti ve studii IDEA</span></a></div>
    <div id="menu">
      <dl id='select_ref' class="dropdown">
        <dt>
      <a href="#"><span>Zvolte reformní scénář pro ČR</span></a>
    </dt>
        <dd>
          <ul>
            <li><a href="#">Mírné zvyšování kvality práce všech učitelů<span class="value">ref1</span></a></li>
            <li><a href="#">Výrazné zvyšování kvality práce všech učitelů<span class="value">ref2</span></a></li>
            <li><a href="#">Generační výměna s důrazem na vysokou kvalitu práce mladých učitelů<span class="value">ref3</span></a></li>
            <li><a href="#">Kombinace zlepšování kvality práce stávajících i nových učitelů (mírné)<span class="value">ref4</span></a></li>
            <li><a href="#">Kombinace zlepšování kvality práce stávajících i nových učitelů (výrazné)<span class="value">ref5</span></a></li>
          </ul>
        </dd>
      </dl>
    </div>
  </div>
  </div>
</body>
              
            
!

CSS

              
                #area {
  display:flex;align-items:flex-end;
  background-color: #404040;
  %border: 1px solid red;
  height: 569px;
  width: 515px;
  position: relative;
  margin: auto;
  margin-top: -10px;
  margin-bottom: -10px;
  overflow: auto;
}

#graph{
  position: absolute;
  left: 10px;
  top: 0px;
}

#menu {
  height: 419px;
  width: 418px;
  position: absolute;
  left: 97px;
  top: 150px;
  z-index: 1;
  display: inline-block;
  text-align: left;
}

/* DT styles for sliding doors */
.dropdown dt a {
  color: #fff;
  background: url("https://raw.githubusercontent.com/threndash/logo/master/caret-down.png") #646464;
  background-repeat: no-repeat;
  background-position: center right;
  background-size: 17.5px 7px;
  display: block;
  padding-right: 15px;
  width: 130px;
  text-decoration: none;
  font-family: "Nunito Sans", sans-serif;
}
.dropdown dt a span {
  cursor: pointer;
  display: block;
  padding: 5px;
  color: #fff;
  text-decoration: none;
  font-family: "Nunito Sans", sans-serif;
}
/* UL styles */
.dropdown dd ul {
  background: #646464 none repeat scroll 0 0;
  display: none;
  list-style: none;
  padding: 5px 0px;
  position: absolute;
  left: 0px;
  top: 2px;
  width: auto;
  min-width: 250px;
}
.dropdown span.value {
  display: none;
}
.dropdown dd ul li a {
  padding: 5px;
  display: block;
  color: #fff;
  outline: none;
  text-decoration: none;
  font-family: "Nunito Sans", sans-serif;
  font-size: 75%;
}
.dropdown dd ul li a:hover {
  background-color: #5a5a5a;
  color: #fff;
  text-decoration: none;
}

.dropdown span.value {
  display: none;
}

.link a {
  color: #fff;
  background: #646464;
  display: inline-block;
  padding: 5px;
  width: 120px;
  text-decoration: none;
  font-family: "Nunito Sans", sans-serif;
  font-size: 14px;
  text-align: center;
}

.link span {
  color: #fff;
  display: inline-block;
  text-decoration: none;
  font-family: "Nunito Sans", sans-serif;
}

.link a:hover {
  background-color: #5a5a5a;
  color: #fff;
  text-decoration: none;
}

#link1 {
  float: left;
  width:33.33333%;
  text-align:left;
  z-index: 2;
  display: inline-block;
  margin: 15px;
}

#link2 {
  float: left;
  width: 33.33333%;
  text-align: right;
  z-index: 2;
  display: inline-block;
  margin: 15px;
}

#logo{
  float: left;
  width:33.33333%;
  text-align:center;
  z-index: 2;
  display: inline-block;
  margin: 20px;
}

img{
  height: 30px;
}
              
            
!

JS

              
                var years = [2020, 2030, 2040, 2050, 2060, 2070, 2080, 2090, 2100];

var ref0 = [1,1.161,1.347,1.563,1.814,2.105,2.443,2.835,3.291,3.819,4.432];

var ref1 = [1,1.162,1.358,1.599,1.899,2.269,2.718,3.256,3.901,4.673,5.597];

var ref2 = [1,1.163,1.369,1.636,1.987,2.445,3.022,3.736,4.619,5.71,7.058];

var ref3 = [1,1.162,1.359,1.611,1.943,2.39,2.986,3.776,4.818,6.187,7.984];

var ref4 = [1,1.163,1.369,1.64,2.006,2.506,3.172,4.048,5.198,6.705,8.679];

var ref5 = [1,1.164,1.378,1.67,2.073,2.634,3.381,4.359,5.64,7.315,9.507];

var de = [1.49,1.73,2.007,2.33,2.704,3.137,3.641,4.226,4.904,5.691,6.605];

var i = 0;

Plotly.newPlot(
  "graph",
  [
    (trace0 = {
      x: years,
      y: ref0,
      mode: "lines",
      line: { shape: "spline", width: 7, color: "#404040" },
      showlegend: false
    }),
    (trace1 = {
      x: years,
      y: ref0,
      mode: "lines",
      line: { shape: "spline", width: 7, color: "#ffff" },
      fill: "tonexty",
      fillcolor: "#0069b4",
      name: "Reformní scénář ČR"
    }),
    (trace2 = {
      x: years,
      y: ref0,
      mode: "lines",
      line: { shape: "spline", width: 7.5, color: "#ff0000" },
      name: "Nereformní scénář ČR"
    }),
    (trace3 = {
      x: [2020, 2030, 2040, 2050, 2060, 2070, 2080, 2090, 2100],
      y: de,
      mode: "lines",
      line: { shape: "spline", width: 7, color: "#f4d442" },
      name: "Německo"
    }),
    (trace4 = {
      x: [2103],
      y: [5],
      type: "scatter",
      mode: "markers",
      marker: {
        color: "#f4d442",
        line: { color: "#404040", width: 2 },
        size: 15
      },
      showlegend: false
    })
  ],
  {
    yaxis: {
      range: [0, 6],
      tickformat: ',.0%',
      title: {
        text: "Roční HDP (v % počátečního HDP ČR)<br>&nbsp;",
        font: {
          family: "Nunito Sans",
          color: "#ffffff",
          size: 18
        }
      },
      showgrid: true,
      showline: true,
      mirror: "ticks",
      gridcolor: "#646464",
      gridwidth: 1,
      linecolor: "#f1f1f1",
      linewidth: 3,
      tickfont: {
        family: "Nunito Sans",
        color: "#ffffff",
        size: 14
      }
    },
    xaxis: {
      range: [2020, 2100],
      title: {
        text: "Roky",
        font: {
          family: "Nunito Sans",
          color: "#ffffff",
          size: 18
        }
      },
      showgrid: true,
      showline: true,
      mirror: "ticks",
      gridcolor: "#646464",
      gridwidth: 1,
      linecolor: "#f1f1f1",
      linewidth: 3,
      tickfont: {
        family: "Nunito Sans",
        color: "#ffffff",
        size: 14
      },
      tickvals: [2020, 2030, 2040, 2050, 2060, 2070, 2080, 2090, 2100]
    },
    title: {
      text:
        "<b>Co mohou Česku<br>ekonomicky přinést investice<br>do vyšší kvality práce učitelů</b>",
      font: {
        family: "Nunito Sans",
        color: "#ffffff",
        size: 32
      },
      yref: "container",
      y: 0.92,
      xref: "container"
    },
    showlegend: true,
    legend: {
      x: 1,
      y: 0,
      xanchor: "right",
      yanchor: "bottom",
      traceorder: "reverse",
      font: {
        size: 13,
        color: "#FFF"
      }
    },
    hovermode: false,
    paper_bgcolor: "#404040",
    plot_bgcolor: "#404040",
    autosize: false,
    width: 495,
    height: 504,
    margin: {
      l: 80,
      r: 50,
      b: 50,
      t: 160,
      pad: 0
    }
  },
  { displayModeBar: false }
);

var select_val = "ref4";

if (select_val === "ref4") {
    Plotly.animate(
      "graph",
      {
        data: [{ y: ref4 }, { x: years, y: ref0 }, { x: [2095], y: [4.568] }],
        traces: [1, 2, 4],
        layout: {}
      },
      {
        transition: {
          duration: 500,
          easing: "cubic-in-out"
        },
        frame: {
          duration: 500
        }
      }
    );
    Plotly.relayout("graph", {
      annotations: [
        {
          x: 2095,
          y: 4.6,
          xref: "x",
          yref: "y",
          xanchor: "right",
          yanchor: "bottom",
          text: "2095",
          font: {
            family: "Nunito Sans",
            color: "#f4d442",
            size: 16
          },
          textangle: 0,
          showarrow: false
        }
      ]
    });
  }

$(".dropdown dd ul li").click(function() {
  select_val = getSelectedValue("select_ref");

  if (select_val === "ref1") {
    Plotly.animate(
      "graph",
      {
        data: [{ y: ref1 }, { x: years, y: ref0 }, { x: [2103], y: [5] }],
        traces: [1, 2, 4],
        layout: {}
      },
      {
        transition: {
          duration: 500,
          easing: "cubic-in-out"
        },
        frame: {
          duration: 500
        }
      }
    );
    Plotly.relayout("graph", {
      annotations: []
    });
  }

  if (select_val === "ref2") {
    Plotly.animate(
      "graph",
      {
        data: [{ y: ref2 }, { x: years, y: ref0 }, { x: [2103], y: [5] }],
        traces: [1, 2, 4],
        layout: {}
      },
      {
        transition: {
          duration: 500,
          easing: "cubic-in-out"
        },
        frame: {
          duration: 500
        }
      }
    );
    Plotly.relayout("graph", {
      annotations: []
    });
  }

  if (select_val === "ref3") {
    Plotly.animate(
      "graph",
      {
        data: [{ y: ref3 }, { x: years, y: ref0 }, { x: [2103], y: [5] }],
        traces: [1, 2, 4],
        layout: {}
      },
      {
        transition: {
          duration: 500,
          easing: "cubic-in-out"
        },
        frame: {
          duration: 500
        }
      }
    );
    Plotly.relayout("graph", {
      annotations: []
    });
  }

  if (select_val === "ref4") {
    Plotly.animate(
      "graph",
      {
        data: [{ y: ref4 }, { x: years, y: ref0 }, { x: [2095], y: [4.568] }],
        traces: [1, 2, 4],
        layout: {}
      },
      {
        transition: {
          duration: 500,
          easing: "cubic-in-out"
        },
        frame: {
          duration: 500
        }
      }
    );
    Plotly.relayout("graph", {
      annotations: [
        {
          x: 2095,
          y: 4.6,
          xref: "x",
          yref: "y",
          xanchor: "right",
          yanchor: "bottom",
          text: "2095",
          font: {
            family: "Nunito Sans",
            color: "#f4d442",
            size: 16
          },
          textangle: 0,
          showarrow: false
        }
      ]
    });
  }

  if (select_val === "ref5") {
    Plotly.animate(
      "graph",
      {
        data: [{ y: ref5 }, { x: years, y: ref0 }, { x: [2088], y: [4.122] }],
        traces: [1, 2, 4],
        layout: {}
      },
      {
        transition: {
          duration: 500,
          easing: "cubic-in-out"
        },
        frame: {
          duration: 500
        }
      }
    );
    Plotly.relayout("graph", {
      annotations: [
        {
          x: 2088,
          y: 4.2,
          xref: "x",
          yref: "y",
          xanchor: "right",
          yanchor: "bottom",
          text: "2088",
          font: {
            family: "Nunito Sans",
            color: "#f4d442",
            size: 16
          },
          textangle: 0,
          showarrow: false
        }
      ]
    });
  }
});

function getSelectedValue(id) {
  return $("#" + id)
    .find("dt a span.value")
    .html();
}

$(".dropdown dt a").click(function(e) {
  $(".dropdown dd ul").toggle();
  e.preventDefault();
});

$(".dropdown dd ul li a").click(function() {
  var text = $(this).html();
  $(".dropdown dt a span").html(text);
  $(".dropdown dd ul").hide();
});

$(document).bind("click", function(e) {
  var $clicked = $(e.target);
  if (!$clicked.parents().hasClass("dropdown")) $(".dropdown dd ul").hide();
});
              
            
!
999px

Console