dev:web: chart.hamlet: reindent, simpler comment syntax
This commit is contained in:
parent
fd0bf6f90d
commit
cb0a0fafa5
@ -8,8 +8,8 @@ $# If $ is the first character in a line, it must be \-escaped to hide it from h
|
||||
\$('#register-chart-label').text('#{charttitle}');
|
||||
var seriesData = [
|
||||
$forall (c,items) <- percommoditytxnreports
|
||||
/* we render each commodity using two series:
|
||||
* one with extra data points added to show a stepped balance line */
|
||||
// we render each commodity using two series:
|
||||
// one with extra data points added to show a stepped balance line
|
||||
{
|
||||
data: [
|
||||
$forall i <- reverse items
|
||||
@ -30,7 +30,7 @@ $# If $ is the first character in a line, it must be \-escaped to hide it from h
|
||||
clickable: false,
|
||||
hoverable: false,
|
||||
},
|
||||
/* and one with the original data, showing one clickable, hoverable point per transaction */
|
||||
// and one with the original data, showing one clickable, hoverable point per transaction
|
||||
{
|
||||
data: [
|
||||
$forall i <- reverse items
|
||||
@ -42,7 +42,6 @@ $# If $ is the first character in a line, it must be \-escaped to hide it from h
|
||||
'#{concat $ intersperse "\\n" $ lines $ T.unpack $ showTransaction $ triOrigTransaction i}',
|
||||
#{tindex $ triOrigTransaction i}
|
||||
],
|
||||
/* [] */
|
||||
],
|
||||
label: '',
|
||||
color: #{colorForCommodity c},
|
||||
@ -53,13 +52,20 @@ $# If $ is the first character in a line, it must be \-escaped to hide it from h
|
||||
show: true,
|
||||
},
|
||||
},
|
||||
]
|
||||
];
|
||||
var plot = registerChart($chartdiv, seriesData);
|
||||
plot.setSelection({ xaxis: { from: 500, to: 700 } }); // ?
|
||||
\$chartdiv.bind("plotclick", registerChartClick);
|
||||
\$chartdiv.bind("plotselected", registerChartSelect);
|
||||
};
|
||||
});
|
||||
|
||||
//eslint-disable-next-line no-unused-vars
|
||||
function registerChart($container, series) {
|
||||
// https://github.com/flot/flot/blob/master/API.md
|
||||
return $container.plot(
|
||||
series,
|
||||
{ /* general chart options */
|
||||
{
|
||||
xaxis: {
|
||||
mode: "time",
|
||||
timeformat: "%Y/%m/%d",
|
||||
@ -100,7 +106,7 @@ $# If $ is the first character in a line, it must be \-escaped to hide it from h
|
||||
autoHighlight: true,
|
||||
clickable: true,
|
||||
},
|
||||
/* https://github.com/krzysu/flot.tooltip */
|
||||
// https://github.com/krzysu/flot.tooltip
|
||||
tooltip: true,
|
||||
tooltipOpts: {
|
||||
xDateFormat: "%Y/%m/%d",
|
||||
@ -116,6 +122,8 @@ $# If $ is the first character in a line, it must be \-escaped to hide it from h
|
||||
}
|
||||
).data("plot");
|
||||
}
|
||||
|
||||
// Handle a click event on the chart.
|
||||
function registerChartClick(ev, pos, item) {
|
||||
if (!item) {
|
||||
return;
|
||||
@ -129,13 +137,15 @@ $# If $ is the first character in a line, it must be \-escaped to hide it from h
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
// Handle a selection (zoom) event on the chart.
|
||||
// This should pick good from/to dates based on the selected x-values, which is tricky to get right.
|
||||
function registerChartSelect(ev, ranges) {
|
||||
console.log("selected", ranges.xaxis.from, ranges.xaxis.to);
|
||||
/* Round down for the 'from' day: */
|
||||
|
||||
// This should pick good from/to dates based on the selected x-values, which is tricky to get right.
|
||||
// Round down for the 'from' day:
|
||||
var from = new Date(ranges.xaxis.from);
|
||||
/* Round up for the 'to' day: */
|
||||
// Round up for the 'to' day:
|
||||
var to = new Date(ranges.xaxis.to + (24 * 60 * 60 * 1000) - 1);
|
||||
var range =
|
||||
from.getFullYear() + "/" + (from.getMonth() + 1) + "/" + from.getDate() + "-" +
|
||||
@ -147,9 +157,3 @@ $# If $ is the first character in a line, it must be \-escaped to hide it from h
|
||||
document.location = baselink + "%20date:" + range;
|
||||
}
|
||||
}
|
||||
var plot = registerChart($chartdiv, seriesData);
|
||||
plot.setSelection({ xaxis: { from: 500, to: 700 } });
|
||||
\$chartdiv.bind("plotclick", registerChartClick);
|
||||
\$chartdiv.bind("plotselected", registerChartSelect);
|
||||
};
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user