fixes
This commit is contained in:
parent
9e97ab9592
commit
9ec6440dc7
@ -24,6 +24,7 @@
|
|||||||
"express-http-proxy": "^1.6.2",
|
"express-http-proxy": "^1.6.2",
|
||||||
"faker": "^4.1.0",
|
"faker": "^4.1.0",
|
||||||
"knex": "^0.21.2",
|
"knex": "^0.21.2",
|
||||||
|
"simplex-noise": "^2.4.0",
|
||||||
"sqlite3": "^5.0.0",
|
"sqlite3": "^5.0.0",
|
||||||
"vue": "^2.6.11",
|
"vue": "^2.6.11",
|
||||||
"vue-chartjs": "^3.5.0",
|
"vue-chartjs": "^3.5.0",
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const faker = require ('faker');
|
const faker = require ('faker');
|
||||||
|
const sn = require ('simplex-noise');
|
||||||
|
|
||||||
function create_log () {
|
function create_log (index, simplex) {
|
||||||
const data = {
|
const data = {
|
||||||
num1: faker.random.number (),
|
num1: faker.random.number (),
|
||||||
num2: faker.random.number (),
|
num2: simplex.noise2D (index * 0.1, 0),
|
||||||
num3: faker.random.number ()
|
num3: simplex.noise2D (index * 0.1, 1000)
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
app: faker.random.word (),
|
app: faker.random.word (),
|
||||||
@ -18,9 +19,10 @@ function create_log () {
|
|||||||
|
|
||||||
async function seed (knex) {
|
async function seed (knex) {
|
||||||
console.log ('creating seeds');
|
console.log ('creating seeds');
|
||||||
|
const simplex = (new sn);
|
||||||
const log = (Array (20))
|
const log = (Array (20))
|
||||||
.fill (() => null)
|
.fill (() => null)
|
||||||
.map (() => create_log ());
|
.map ((a, index) => create_log (index, simplex));
|
||||||
await knex ('log')
|
await knex ('log')
|
||||||
.del ();
|
.del ();
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
<script>
|
<script>
|
||||||
import { Line, mixins } from 'vue-chartjs';
|
import { Line, mixins } from 'vue-chartjs';
|
||||||
|
|
||||||
function resolve_data (set, keys) {
|
function resolve_data (set, index) {
|
||||||
|
const keys = typeof index === 'string' ? index.split ('/') : index;
|
||||||
const data = set[keys[0]];
|
const data = set[keys[0]];
|
||||||
if (keys.length === 1)
|
if (keys.length === 1)
|
||||||
return data;
|
return data;
|
||||||
@ -27,7 +28,7 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
chart_data () {
|
chart_data () {
|
||||||
const labels = this.data.map ((d) => d[this.xaxis]);
|
const labels = this.data.map ((d) => resolve_data (d, this.xaxis));
|
||||||
const datasets = this.yaxis.map ((y, index) => {
|
const datasets = this.yaxis.map ((y, index) => {
|
||||||
const res = {
|
const res = {
|
||||||
label: y.label,
|
label: y.label,
|
||||||
@ -37,7 +38,7 @@ export default {
|
|||||||
backgroundColor: y.fill
|
backgroundColor: y.fill
|
||||||
};
|
};
|
||||||
for (const data of this.data)
|
for (const data of this.data)
|
||||||
res.data.push (resolve_data (data, y.field.split ('/')));
|
res.data.push (resolve_data (data, y.field));
|
||||||
return res;
|
return res;
|
||||||
});
|
});
|
||||||
return { datasets, labels };
|
return { datasets, labels };
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
/>
|
/>
|
||||||
<ChartView
|
<ChartView
|
||||||
:data="parsed_log"
|
:data="parsed_log"
|
||||||
xaxis="app"
|
xaxis="timestamp"
|
||||||
:yaxis="datasets"
|
:yaxis="datasets"
|
||||||
/>
|
/>
|
||||||
<TableView
|
<TableView
|
||||||
@ -38,9 +38,8 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
datasets () {
|
datasets () {
|
||||||
return [
|
return [
|
||||||
{ label: 'test', field: 'data/num2', color: 'blue', fill: '#0000' },
|
{ label: 'foo', field: 'data/num2', color: '#ff000055', fill: '#0000' },
|
||||||
{ label: 'abc', field: 'data/num1', color: '#ff000055', fill: '#0000' },
|
{ label: 'bar', field: 'data/num3', color: '#00ff00', fill: '#0000' }
|
||||||
{ label: 'def', field: 'data/num1', color: '#00ff00', fill: '#f005' }
|
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
parsed_log () {
|
parsed_log () {
|
||||||
|
@ -7790,6 +7790,11 @@ simple-swizzle@^0.2.2:
|
|||||||
dependencies:
|
dependencies:
|
||||||
is-arrayish "^0.3.1"
|
is-arrayish "^0.3.1"
|
||||||
|
|
||||||
|
simplex-noise@^2.4.0:
|
||||||
|
version "2.4.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/simplex-noise/-/simplex-noise-2.4.0.tgz#81b3458fb22dccc3bc8dd9a977c73797f86f523a"
|
||||||
|
integrity sha512-OjyDWm/QZjVbMrPxDVi9b2as+SeNn9EBXlrWVRlFW+TSyWMSXouDryXkQN0vf5YP+QZKobrmkvx1eQYPLtuqfw==
|
||||||
|
|
||||||
slash@^1.0.0:
|
slash@^1.0.0:
|
||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55"
|
resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user