Skip to content

Commit

Permalink
v0.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
samussiah committed Jun 13, 2019
1 parent 34cf577 commit 0b17d93
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 17 deletions.
49 changes: 40 additions & 9 deletions dashboardFramework.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
global.dashboardCharts,
global.webCharts
)));
})(this, function(d3$1, dashboardCharts$1, webcharts) {
})(this, function(d3, dashboardCharts, webcharts) {
'use strict';

if (typeof Object.assign != 'function') {
Expand Down Expand Up @@ -144,6 +144,30 @@
return _typeof(obj);
}

function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
}

function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];

return arr2;
}
}

function _iterableToArray(iter) {
if (
Symbol.iterator in Object(iter) ||
Object.prototype.toString.call(iter) === '[object Arguments]'
)
return Array.from(iter);
}

function _nonIterableSpread() {
throw new TypeError('Invalid attempt to spread non-iterable instance');
}

function clone(obj) {
var copy; //boolean, number, string, null, undefined

Expand Down Expand Up @@ -200,14 +224,14 @@

function layout() {
this.containers = {
main: d3$1
main: d3
.select(this.element)
.append('div')
.datum(this)
.classed('dashboard-framework', true)
.attr(
'id',
'dashboard-framework'.concat(d3$1.selectAll('.dashboard-framework').size() + 1)
'dashboard-framework'.concat(d3.selectAll('.dashboard-framework').size() + 1)
)
};
}
Expand Down Expand Up @@ -498,22 +522,28 @@
checkArguments$1.call(this, charts);
charts.forEach(function(chart) {
if (
dashboardCharts !== undefined &&
window &&
window.dashboardCharts !== undefined &&
chart.hasOwnProperty('identifier') &&
dashboardCharts$1.specifications[chart.identifier] !== undefined
dashboardCharts.specifications[chart.identifier] !== undefined
) {
var specification = _this.clone(dashboardCharts$1.specifications[chart.identifier]);
var specification = _this.clone(dashboardCharts.specifications[chart.identifier]);

specification.identifier = chart.identifier;
specification.data = chart.data;
specification.title = chart.title || specification.schema.title;
if (chart.settings)
specification.settings = deepmerge(specification.settings, chart.settings);
specification.settings = deepmerge(specification.settings, chart.settings, {
arrayMerge: function arrayMerge(target, source) {
return _toConsumableArray(source);
}
});
if (chart.controlInputs) specification.controlInputs = chart.controlInputs;
if (chart.callbacks)
for (var callback in chart.callbacks) {
specification.callbacks[callback] = chart.callbacks[callback];
}
if (chart.data_callback) specification.data_callback = chart.data_callback;

_this.addChart(specification);
} else _this.addChart(chart.specification);
Expand Down Expand Up @@ -986,12 +1016,13 @@

//Intialize chart.
if (typeof chart.data === 'string') {
d3$1.csv(
d3.csv(
chart.data,
function(d) {
return d;
},
function(data) {
if (chart.data_callback) chart.data_callback(data);
chart.data = data;
checkRequiredVariables.call(_this, chart);
addVariableSelect.call(_this, chart);
Expand All @@ -1008,6 +1039,7 @@
}
);
} else if (Array.isArray(chart.data)) {
if (chart.data_callback) chart.data_callback(data);
checkRequiredVariables.call(this, chart);
addVariableSelect.call(this, chart);

Expand All @@ -1027,7 +1059,6 @@
var _this = this;

this.charts.forEach(function(chart) {
console.log(chart);
setTitle.call(_this, chart);
callCreateControls.call(_this, chart);
enforceChartSizing.call(_this, chart);
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dashboard-framework",
"version": "0.1.2",
"version": "0.1.4",
"description": "webpage framework in which to place charts in a grid",
"module": "src/index.js",
"main": "dashboardFramework.js",
Expand Down
8 changes: 6 additions & 2 deletions src/addChartList.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ export default function addChartList(charts) {
checkArguments.call(this, charts);
charts.forEach(chart => {
if (
dashboardCharts !== undefined &&
window &&
window.dashboardCharts !== undefined &&
chart.hasOwnProperty('identifier') &&
specifications[chart.identifier] !== undefined
) {
Expand All @@ -15,11 +16,14 @@ export default function addChartList(charts) {
specification.data = chart.data;
specification.title = chart.title || specification.schema.title;
if (chart.settings)
specification.settings = deepmerge(specification.settings, chart.settings);
specification.settings = deepmerge(specification.settings, chart.settings, {
arrayMerge: (target, source) => [...source]
});
if (chart.controlInputs) specification.controlInputs = chart.controlInputs;
if (chart.callbacks)
for (const callback in chart.callbacks)
specification.callbacks[callback] = chart.callbacks[callback];
if (chart.data_callback) specification.data_callback = chart.data_callback;
this.addChart(specification);
} else this.addChart(chart.specification);
});
Expand Down
1 change: 0 additions & 1 deletion src/init/drawCharts.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import initializeChart from './drawcharts/initializeChart';

export default function drawCharts() {
this.charts.forEach(chart => {
console.log(chart);
setTitle.call(this, chart);
callCreateControls.call(this, chart);
enforceSizing.call(this, chart);
Expand Down
2 changes: 2 additions & 0 deletions src/init/drawCharts/initializeChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default function initializeChart(chart) {
return d;
},
data => {
if (chart.data_callback) chart.data_callback(data);
chart.data = data;
checkRequiredVariables.call(this, chart);
addVariableSelect.call(this, chart);
Expand All @@ -26,6 +27,7 @@ export default function initializeChart(chart) {
}
);
} else if (Array.isArray(chart.data)) {
if (chart.data_callback) chart.data_callback(data);
checkRequiredVariables.call(this, chart);
addVariableSelect.call(this, chart);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { select } from 'd3';
import updateWarning from './updateWarning';
import updateSubmit from './updateSubmit';

Expand All @@ -9,12 +10,12 @@ export default function updateSchema(chart) {
d => chart.variables.missing.map(variable => variable.key).indexOf(d.key) > -1
);
chart.containers.schemaOptions.property('selected', function(d) {
const dropdown = d3.select(this.parentNode);
const dropdown = select(this.parentNode);
return dropdown.datum().current === d;
});
chart.containers.schemaDropdowns.on('change', function(d) {
const schemaContainer = d3.select(this.parentNode);
const dropdown = d3.select(this);
const schemaContainer = select(this.parentNode);
const dropdown = select(this);
const option = dropdown.selectAll('option:checked').text();

//user selects variable
Expand Down

0 comments on commit 0b17d93

Please sign in to comment.