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

              
                mixin badge-split(prop, val, type)
  span.mr-2
    span.badge.badge-secondary._cap-right= prop
    span(class="badge _cap-left badge-" + type)= val

mixin color(color)
  span.badge(style="background-color: " + color + "; color: transparent;") hello


.body.bg-light
  // Masthead =======================================================
  .masthead.bg-white.mb-3
    // Navbar
    nav.navbar.navbar-expand-lg.navbar-light.mb-3
      a.navbar-brand(href='#')
        img(src="http://via.placeholder.com/46x46")
      button.navbar-toggler(type='button', data-toggle='collapse', data-target='#navbarSupportedContent', aria-controls='navbarSupportedContent', aria-expanded='false', aria-label='Toggle navigation')
        span.navbar-toggler-icon
      #navbarSupportedContent.collapse.navbar-collapse
        form.form-inline.my-2.my-lg-0.w-100
          input.form-control.form-control-lg.border-0.w-100.bg-light(type='search', placeholder='Search', aria-label='Search')
          button.sr-only(type='submit') Search...

    // Filters
    .container-fluid.pb-3: .row: .col-12.d-flex.align-items-center
      div
        .input-group
          .input-group-prepend
            .input-group-text.bg-white.pr-0
              i.material-icons date_range
          input.form-control.range-picker.border-left-0(type='text', aria-label='Text input with radio button')

      .d-flex.ml-auto
        // Quality
        .form-group.form-inline.mb-0.mr-3
          label.small.text-muted(for='exampleFormControlSelect1') Quality:
            select.ml-2.form-control.form-control-sm
              option Low
              option Medium
              option High
        // Perf
        .form-group.form-inline.mb-0.mr-3
          label.small.text-muted(for='exampleFormControlSelect1') Performance:
            select.ml-2.form-control.form-control-sm
              option Low
              option Medium
              option High
        // Color
        .form-group.form-inline.mb-0.mr-3
          label.small.text-muted(for='exampleFormControlSelect1') Color:
            select.ml-2.form-control.form-control-sm
              option Pink
              option Purple
              option Who cares
              
  // Data ====================================================
  .container-fluid.content
    .row
      main.col-4
        ul
          - var n = 0;
          while n < 8
            Li
              - n++
              // Date
              h2.mb-0 01/09/2018
              // Quality and perfs tags
              p.mb-2 
                +badge-split("quality", "High", "success")
                +badge-split("Performance", "Medium", "warning")
              samp.text-muted.mb-3.d-block Offset: 13, Pressure: 758467839, Layout: 1796, Component: Yotis3, Colorbound: #[+color("purple")], Result: 0

              
            
          
      aside.col-8
        .row
          .col-6: canvas(id="graph_quality_lot", width="400", height="400")
          .col-6: canvas(id="graph_quality_component", width="400", height="400")
          .col-6: canvas(id="graph_performance_layout", width="400", height="400")
          .col-6: canvas(id="graph_lot_color", width="400", height="400")

              
            
!

CSS

              
                ._cap-right
  border-bottom-right-radius: 0px
  border-top-right-radius: 0px
  
._cap-left
  border-bottom-left-radius: 0px
  border-top-left-radius: 0px
  
.material-icons
  vertical-align: middle
  
.masthead
  box-shadow: 0 4px 5px 0 rgba(0,0,0,0.14), 0 1px 10px 0 rgba(0,0,0,0.12), 0 2px 4px -1px rgba(0,0,0,0.2)
  
.body 
  min-height: 100vh
  
.-square
  &:before
    display: block
    content: ''
    padding-top: 100%

  position: relative
  
.-swatch
  width: 25px
  display: inline-block

samp
  line-height: 1.3
// @todo: use purple as main 

.-chart
  width: 100%
  min-height: 450px
  
ul
  list-style-type: disc
  padding-left: 15px
  
.content samp,
.content h2,
.content p
  font-size: 14px
              
            
!

JS

              
                console.clear();

/**
 * Date Picker
 */

$(".range-picker").daterangepicker();

// GRAPHS ------------------------------------------------------------
/**
 * Data adapter
 */

/**
 * Turns array of objects into dictionnary
 *
 * [{thing: "stuff"}, {thing: "else"}]
 * => {thing: ["stuff","else"]}
 */
class Dictionnary {
  constructor(arr) {
    this._dictionnary = arr.reduce((acc, curr) => {
      let _acc = { ...acc };

      Object.keys(curr).map(
        key =>
          (_acc[key] = _acc[key] // { labels: acc.label + curr.label || [ curr.label ] }
            ? [..._acc[key], curr[key]]
            : [curr[key]])
      );

      return _acc;
    }, {});
  }

  getAll() {
    return this._dictionnary;
  }
}

class DictionnaryToChartAdapter {
  constructor(dictionnary, labelKey, colorMatcher) {
    this.labels = [...dictionnary[labelKey]];

    this.datasets = Object.keys(dictionnary) // { LotNumber: ["stuff", "other"], high: [0, 1, 2]}
      .filter(k => k !== labelKey) // Remove label key from datasets to display
      .map(key => ({
        label: key,
        data: dictionnary[key],
        backgroundColor: colorMatcher[key] || "purple"
      })); // Turn into chartjs data
  }

  getLabels() {
    return this.labels;
  }

  getDatasets() {
    return this.datasets;
  }
}

/**
 * Color key match object for graph colors
 */
const colors = {
  green: "#4bc0c0",
  blue: "#36a1eb",
  red: "#ff6383",
  yellow: "#ffcd55"
};
const colorKeyMatch = {
  High: colors.green,
  Medium: colors.blue,
  Low: colors.red,
  Count: [colors.blue,colors.green,colors.red, colors.yellow]
};

/**
 * Graphs mock data
 */
let graph_quality_component = new Dictionnary([
    { Name: "Yotis3", High: 0, Medium: 1, Low: 0 },
    { Name: "Yotis4", High: 1, Medium: 0, Low: 0 },
    { Name: "Yotis5", High: 0, Medium: 0, Low: 1 },
    { Name: "Yotis6", High: 1, Medium: 1, Low: 0 }
  ]).getAll(),
  graph_quality_lot = new Dictionnary([
    { LotNumber: 1124472695, High: 1, Medium: 1, Low: 1 },
    { LotNumber: 1124472744, High: 0, Medium: 1, Low: 1 },
    { LotNumber: 1124476323, High: 1, Medium: 1, Low: 0 },
    { LotNumber: 1124476334, High: 0, Medium: 0, Low: 1 }
  ]).getAll(),
  graph_performance_layout = new Dictionnary([
    { Layout: 1244, High: 0, Medium: 1, Low: 0 },
    { Layout: 1356, High: 0, Medium: 1, Low: 1 },
    { Layout: 1748, High: 0, Medium: 1, Low: 0 },
    { Layout: 1755, High: 1, Medium: 0, Low: 0 },
    { Layout: 2268, High: 1, Medium: 0, Low: 0 }
  ]).getAll(),
  graph_lot_color = new Dictionnary([
    { Name: "Blue", Count: 4 },
    { Name: "Green", Count: 1 },
    { Name: "Red", Count: 2 },
    { Name: "Yellow", Count: 1 }
  ]).getAll();


graph_quality_component = new DictionnaryToChartAdapter( graph_quality_component, "Name", colorKeyMatch );
graph_quality_lot = new DictionnaryToChartAdapter( graph_quality_lot, "LotNumber", colorKeyMatch );
graph_performance_layout = new DictionnaryToChartAdapter( graph_performance_layout, "Layout", colorKeyMatch );
graph_lot_color = new DictionnaryToChartAdapter( graph_lot_color, "Name", colorKeyMatch );


const chart_opts_default = {
  type: "bar",
  options: {
      scales: {
        xAxes: [ { stacked: true } ],
        yAxes: [ { stacked: true } ]
      },
      title: {
          display: true,
      }
    }
}

const charts = [
  { id: "graph_quality_lot", title: "Quality/Lot", opts: {data: graph_quality_lot} },
  { id: "graph_quality_component", title: "Quality/Componponent", opts: {data: graph_quality_component} },
  { id: "graph_performance_layout", title: "Performance/Layout", opts: {data: graph_performance_layout} },
  { id: "graph_lot_color", title: "Lot/Color", opts: {type: "pie", data: {
    ...graph_lot_color
  }} }
]

charts.forEach(config => {
  
    let chart = new Chart(
      document.getElementById(config.id).getContext("2d"), {
        ...chart_opts_default, 
        ...config.opts                  
      } )
    
    chart.options.title.text = config.title
   
  
})




              
            
!
999px

Console