Commit b33d51b6 authored by Tomas Pettersson's avatar Tomas Pettersson 🏸

chart init

parent 3ecd8612
......@@ -63,42 +63,105 @@ var Graph = (function () {
$(selectionForm).submit(function (e) {
return false;
});
var chartColors = {
red: 'rgb(255, 99, 132)',
orange: 'rgb(255, 159, 64)',
yellow: 'rgb(255, 205, 86)',
green: 'rgb(75, 192, 192)',
blue: 'rgb(54, 162, 235)',
purple: 'rgb(153, 102, 255)',
grey: 'rgb(231,233,237)'
};
$('#' + targetid).on({
'show.uk.modal': function () {
var timeFormat = 'YYYY-MM-DD HH:mm';
self.chart = new Chart(self.chartCanvas, {
type: 'line',
data: {
datasets: [{
label: 'Scatter Dataset',
data: []
fill: false,
borderColor: chartColors.red,
label: 'Dispersed oil'
},
{
fill: false,
borderColor: chartColors.orange,
label: 'Oil on Seabed'
},
{
fill: false,
borderColor: chartColors.yellow,
label: 'Oil on shore'
},
{
fill: false,
borderColor: chartColors.green,
label: 'Oil at surface'
},
{
fill: false,
borderColor: chartColors.blue,
label: 'Oil volume'
}]
},
options: {
legend: {
onClick: function (event, legendItem) {
(legendItem.hidden) ? self.chart.data.datasets[legendItem.datasetIndex].hidden = false : self.chart.data.datasets[legendItem.datasetIndex].hidden = true;
self.chart.update();
}
},
maintainAspectRatio: false,
scales: {
xAxes: [{
type: 'linear',
position: 'bottom'
type: 'time',
display: true,
scaleLabel: {
display: true,
labelString: 'Timeperiod'
},
time: {
unit: 'hour',
displayFormats: {
'hour': 'YYYY-MM-DD HH'
}
},
ticks: {
autoSkip: true,
maxTicksLimit: 20
}
}],
yAxes: [{
display: true,
scaleLabel: {
display: true,
labelString: 'm3'
}
}]
}
}
});
function addData(dataset, datearray, dataarray) {
for (var i = 0; i < dataarray.length; i++) {
dataset.data.push({
x: moment.utc(datearray.datetime[i]).format(timeFormat),
y: dataarray[i]
});
}
}
reqwest({
url: "/demo/graph/" + self.id,
method: 'get',
type: 'json',
success: function (jsondata) {
console.log(jsondata);
self.chart.data.datasets[0].data = [{
x: -10,
y: 0
}, {
x: 0,
y: 10
}, {
x: 10,
y: 5
}];
if (jsondata.cubicmeter) {
addData(self.chart.data.datasets[0], jsondata.millisecond, jsondata.cubicmeter.dispersed);
addData(self.chart.data.datasets[1], jsondata.millisecond, jsondata.cubicmeter.seabed);
addData(self.chart.data.datasets[2], jsondata.millisecond, jsondata.cubicmeter.shore);
addData(self.chart.data.datasets[3], jsondata.millisecond, jsondata.cubicmeter.surface);
addData(self.chart.data.datasets[4], jsondata.millisecond, jsondata.cubicmeter.volume);
}
self.chart.update();
}
});
......
{"version":3,"file":"stw-padmws-graph.js","sourceRoot":"","sources":["stw-padmws-graph.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,wCAAwC;AACxC,yCAAyC;AACzC,mDAAmD;AAGnD;IAQI,eAAY,QAAQ,EAAE,EAAE,EAAE,OAAO;QAC7B,IAAI,IAAI,GAAG,IAAI,CAAC;QAChB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;YACf,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAC/C,CAAC;QACD,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;YACnB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACrC,CAAC;QAGD,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;YAChB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAC/C,CAAC;QAAC,IAAI,CAAC,CAAC;YACJ,OAAO,CAAC;gBACJ,GAAG,EAAE,aAAa,GAAG,IAAI,CAAC,IAAI,GAAG,OAAO;gBACxC,MAAM,EAAE,KAAK;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AC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;4BACvF,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;4BACtF,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;4BACxF,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;wBAC3F,CAAC;wBACD,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;oBAExB,CAAC;iBACJ,CAAC,CAAC;YAEP,CAAC;SACJ,CAAC,CAAC;IACP,CAAC;IACL,YAAC;AAAD,CAAC,AA3LD,IA2LC"}
\ No newline at end of file
......@@ -81,42 +81,108 @@ class Graph {
return false;
});
var chartColors = {
red: 'rgb(255, 99, 132)',
orange: 'rgb(255, 159, 64)',
yellow: 'rgb(255, 205, 86)',
green: 'rgb(75, 192, 192)',
blue: 'rgb(54, 162, 235)',
purple: 'rgb(153, 102, 255)',
grey: 'rgb(231,233,237)'
};
$('#'+targetid).on({
'show.uk.modal': function () {
var timeFormat = 'YYYY-MM-DD HH:mm';
self.chart = new Chart(self.chartCanvas, {
type: 'line',
type: 'line',
data: {
datasets: [{
label: 'Scatter Dataset',
data: []
fill: false,
borderColor: chartColors.red,
label: 'Dispersed oil'
},
{
fill: false,
borderColor: chartColors.orange,
label: 'Oil on Seabed'
},
{
fill: false,
borderColor: chartColors.yellow,
label: 'Oil on shore'
},
{
fill: false,
borderColor: chartColors.green,
label: 'Oil at surface'
},
{
fill: false,
borderColor: chartColors.blue,
label: 'Oil volume'
}]
},
options: {
legend: {
onClick: function(event, legendItem) {
(legendItem.hidden)?self.chart.data.datasets[legendItem.datasetIndex].hidden = false:self.chart.data.datasets[legendItem.datasetIndex].hidden = true;
self.chart.update();
}
},
maintainAspectRatio: false,
scales: {
xAxes: [{
type: 'linear',
position: 'bottom'
}]
type: 'time',
display: true,
scaleLabel: {
display: true,
labelString: 'Timeperiod'
},
time: {
unit: 'hour',
displayFormats: {
'hour': 'YYYY-MM-DD HH'
}
},
ticks: {
autoSkip: true,
maxTicksLimit: 20
}
}],
yAxes: [{
display: true,
scaleLabel: {
display: true,
labelString: 'm3'
}
}]
}
}
});
function addData(dataset, datearray, dataarray) {
for (var i = 0; i < dataarray.length; i++) {
dataset.data.push({
x: moment.utc(datearray.datetime[i]).format(timeFormat),
y : dataarray[i]
});
}
}
reqwest({
url: "/demo/graph/" + self.id,
method: 'get',
type: 'json',
success: function (jsondata) {
console.log(jsondata);
self.chart.data.datasets[0].data = [{
x: -10,
y: 0
}, {
x: 0,
y: 10
}, {
x: 10,
y: 5
}];
if (jsondata.cubicmeter) {
addData(self.chart.data.datasets[0], jsondata.millisecond, jsondata.cubicmeter.dispersed);
addData(self.chart.data.datasets[1], jsondata.millisecond, jsondata.cubicmeter.seabed);
addData(self.chart.data.datasets[2], jsondata.millisecond, jsondata.cubicmeter.shore);
addData(self.chart.data.datasets[3], jsondata.millisecond, jsondata.cubicmeter.surface);
addData(self.chart.data.datasets[4], jsondata.millisecond, jsondata.cubicmeter.volume);
}
self.chart.update();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment