Skip to content
Snippets Groups Projects
Commit 3063dc61 authored by Kevin Hill's avatar Kevin Hill
Browse files

forgot all the changes for the last commit

parent dc769e48
No related branches found
No related tags found
No related merge requests found
.idea/
node_modules/
renders/
renders/*.png
Source diff could not be displayed: it is too large. Options to address this: view the blob.
import glob from 'glob';
import { pullAll, map } from 'lodash';
import { map } from 'lodash';
import { cwd } from 'process';
import { resolve } from 'path';
import { sync as globSync } from 'glob';
 
export default function getChartTypes(callback) {
glob('*.php', {
export default function getChartTypes() {
let chartTypes = globSync('*.php', {
cwd: resolve(cwd(), '../src/Charts/'),
nomount: true
}, (err, chartTypes) => {
pullAll(chartTypes, [
nomount: true,
ignore: [
'Chart.php',
'ChartBuilder.php',
'ChartFactory.php',
]);
]
});
 
callback(map(chartTypes, chartType => {
return chartType.slice(0, -4);
}));
return map(chartTypes, chartType => {
return chartType.slice(0, -4);
});
}
Loading
Loading
@@ -30,8 +30,7 @@ export default function renderChart(chartType) {
console.log('Saved screenshot to ' + chartImg);
 
server.closeServer();
})
// .then();
});
});
 
}
/* jshint node:true */
 
import gulp from 'gulp';
import args from 'yargs';
import yargs from 'yargs';
import bump from 'gulp-bump';
import replace from 'gulp-replace';
import compile from './gulp-functions/Compile';
import renderChart from './gulp-functions/Renderer';
import getChartTypes from './gulp-functions/GetChartTypes';
import { map as promiseMap } from 'bluebird';
import { map, head, chunk } from 'lodash';
import { cpus } from 'os'
import { map } from 'bluebird';
 
gulp.task('default', ['dev']);
 
Loading
Loading
@@ -24,66 +24,69 @@ gulp.task('watch', () => { compile(false, true, false) });
gulp.task('sync', () => { compile(false, true, true) });
 
/**
* Get all available chart types
* Render a specific chart.
*
* Specify the type as the php class name
*
* Syntax:
* gulp charts
* gulp render --type [ AreaChart | LineChart | GeoChart | etc... ]
*/
gulp.task('charts', done => {
getChartTypes(chartTypes => {
console.log(chartTypes.join(', '));
gulp.task('render', done => {
const chartTypes = getChartTypes();
const args = yargs
.fail(msg => {
throw new Error(msg);
})
.alias('t', 'type')
.describe('t', 'choose the type of chart to render')
.choices('t', chartTypes)
.wrap(70)
.help('help')
.argv;
 
done();
});
renderChart(args.t)
.then(() => {
done();
})
.catch(err => {
console.log(err);
});
});
 
/**
* Render a specific chart.
* Render all of the available charts.
*
* Specify the type as the php class name
* The renders will be ran in batches equal to the number of processors.
*
* Syntax:
* gulp render -t [ AreaChart | LineChart | GeoChart | etc... ]
* gulp renderAll
*/
gulp.task('render', done => {
// let chartType = args.type.replace(/\b[a-z]/g, letter => {
// return letter.toUpperCase();
// });
let chartType = args.t;
gulp.task('renderAll', done => {
let batchSize = cpus().length;
 
getChartTypes(chartTypes => {
if (chartTypes.indexOf(chartType) === -1) {
return done(chartType + ' is not a valid chart type.');
}
console.log('Rendering charts in batches of '+batchSize);
 
renderChart(args.type)
.then(() => {
done();
})
.catch(err => {
console.log(err);
});
map(getChartTypes(), chartType => {
return renderChart(chartType);
}, {concurrency: batchSize})
.then(() => {
done();
})
.catch(err => {
console.log(err);
});
});
 
/**
* Render all of the available charts.
* Get all available chart types
*
* Syntax:
* gulp render:all
* gulp charts
*/
gulp.task('renderAll', done => {
getChartTypes(chartTypes => {
promiseMap(chartTypes, chartType => {
return renderChart(chartType);
}, {concurrency: 3})
.then(() => {
done();
})
.catch(err => {
console.log(err);
});
});
gulp.task('charts', done => {
console.log('Available charts for rendering:');
console.log(getChartTypes().join(', '));
done();
});
 
/**
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment