Skip to content

Commit

Permalink
Merge pull request #40 from brown-ccv/feat-charts
Browse files Browse the repository at this point in the history
Port Dashboard and Charting components from Buoy Viewer
  • Loading branch information
mcmcgrath13 authored Oct 29, 2020
2 parents f6f0dd6 + 2609ce6 commit 36e20e5
Show file tree
Hide file tree
Showing 32 changed files with 1,882 additions and 131 deletions.
16 changes: 8 additions & 8 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
module.exports = {
root: true,
env: {
node: true
node: true,
},
extends: ['plugin:vue/essential', 'eslint:recommended', '@vue/prettier'],
parserOptions: {
parser: 'babel-eslint'
parser: 'babel-eslint',
},
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off'
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
},
overrides: [
{
files: [
'**/__tests__/*.{j,t}s?(x)',
'**/tests/unit/**/*.spec.{j,t}s?(x)'
'**/tests/unit/**/*.spec.{j,t}s?(x)',
],
env: {
jest: true
}
}
]
jest: true,
},
},
],
};
2 changes: 1 addition & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
singleQuote: true,
semi: true
semi: true,
};
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ module.exports = {
],
coverageReporters: ['html', 'text-summary'],
coverageDirectory: 'coverage',
setupFiles: ['jest-canvas-mock'],
};
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,15 @@
"deploy": "firebase deploy"
},
"dependencies": {
"@brown-ccv/disco-styles": "2.2.2",
"@brown-ccv/disco-styles": "2.3.0",
"@fortawesome/free-brands-svg-icons": "^5.14.0",
"@fortawesome/vue-fontawesome": "2",
"bulma": "^0.9.0",
"bulma-helpers": "^0.3.12",
"lodash": "^4.17.20",
"vega": "^5.17.0",
"vega-embed": "^6.12.2",
"vega-lite": "^4.17.0",
"vue-bulma": "0.0.35",
"vue-svg-loader": "^0.16.0"
},
Expand Down Expand Up @@ -76,7 +80,7 @@
"@vue/test-utils": "1.0.4",
"babel-eslint": "^10.1.0",
"babel-preset-vue": "^2.0.2",
"chromedriver": "^84.0.1",
"chromedriver": "^86.0.0",
"cross-env": "^7.0.2",
"cz-conventional-changelog": "^3.1.0",
"eslint": "^7.7.0",
Expand All @@ -85,6 +89,7 @@
"firebase-tools": "^8.8.1",
"geckodriver": "^1.20.0",
"git-cz": "^4.7.0",
"jest-canvas-mock": "^2.3.0",
"lint-staged": "^10.2.11",
"minimist": "^1.2.5",
"nightwatch-accessibility": "^1.8.0",
Expand Down
1 change: 1 addition & 0 deletions src/components/d-banner.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<button
@click="dismiss()"
class="d-button-delete is-pulled-right"
aria-label="dismiss"
data-testid="dismiss"
></button>
<div
Expand Down
13 changes: 13 additions & 0 deletions src/components/d-base-dashboard.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<template>
<main>
<nav class="dashboard-nav">
<slot name="nav"></slot>
</nav>
<header class="dashboard-header">
<slot name="header"></slot>
</header>
<section class="dashboard-section">
<slot name="section"></slot>
</section>
</main>
</template>
27 changes: 27 additions & 0 deletions src/components/d-chart-container.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<template>
<div class="chart-container" :class="['is-' + width]">
<header class="chart-header">
<h2 class="title"><slot name="title"></slot></h2>
<h3 class="description"><slot name="description"></slot></h3>
</header>
<section class="chart">
<slot name="chart"></slot>
</section>
</div>
</template>

<script>
export default {
props: {
width: {
type: String,
default: 'full',
validator: function (value) {
return (
['full', 'one-third', 'half', 'two-thirds'].indexOf(value) !== -1
);
},
},
},
};
</script>
107 changes: 107 additions & 0 deletions src/components/d-chart-heatmap.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<script>
import vegaBaseMixin from '@/mixins/vega-base-mixin.js';
export default {
mixins: [vegaBaseMixin],
props: {
variable: {
type: String,
required: true,
},
x: {
type: String,
required: true,
},
xLabel: {
type: String,
required: true,
},
y: {
type: String,
required: true,
},
yLabel: {
type: String,
required: true,
},
},
computed: {
baseSpec() {
return {
$schema: 'https://vega.github.io/schema/vega/v5.json',
height: this.height,
data: {
name: 'data',
values: this.dataset,
},
scales: [
{
name: 'x',
type: 'band',
domain: { data: 'data', field: this.x },
range: 'width',
},
{
name: 'y',
type: 'band',
domain: { data: 'data', field: this.y },
range: 'height',
},
{
name: 'color',
type: 'linear',
range: { scheme: 'tealblues' },
domain: { data: 'data', field: this.variable },
reverse: false,
zero: false,
nice: true,
},
],
axes: [
{
orient: 'bottom',
scale: 'x',
domain: false,
title: this.xLabel,
labelOverlap: 'parity',
},
{
orient: 'left',
scale: 'y',
domain: false,
title: this.yLabel,
},
],
legends: [
{
title: this.variable,
fill: 'color',
type: 'gradient',
gradientLength: { signal: 'height' },
},
],
marks: [
{
type: 'rect',
from: { data: 'data' },
encode: {
enter: {
x: { scale: 'x', field: this.x },
y: { scale: 'y', field: this.y },
width: { scale: 'x', band: 1 },
height: { scale: 'y', band: 1 },
tooltip: {
signal: `{'${this.xLabel}': datum.${this.x}, '${this.yLabel}': datum.${this.y}, 'Count': datum.${this.variable}}`,
},
},
update: {
fill: { scale: 'color', field: this.variable },
},
},
},
],
};
},
},
};
</script>
Loading

0 comments on commit 36e20e5

Please sign in to comment.