Commit 02831efb authored by Nina Willems's avatar Nina Willems

[client/timeserie] plot without negative scaling

parent 853f67d3
......@@ -261,6 +261,7 @@ const incrementDate = (date: Date, interval: Interval): Date => {
const axisX = (width: number, data: PlotData, interval: Interval) => {
// const type = getSelectedKind().getOrElse('ground-quantity');
const color = '#000000';
const yHeight = graphsize.height;
const range = getIntervalTime(interval);
const nbUnit = Math.ceil(xMillisecondRange(data, interval) / range);
const unit = (width - innerPadding.left - innerPadding.right) / nbUnit;
......@@ -270,11 +271,11 @@ const axisX = (width: number, data: PlotData, interval: Interval) => {
const xWidth = graphsize.width - YAXISDISTANCE * data.length;
const axis = [
line(0, 0, xWidth, 0, { stroke: color }),
line(xWidth - 5, -3, xWidth, 0, { stroke: color }),
line(xWidth - 5, 3, xWidth, 0, { stroke: color }),
text(xWidth, -5, `${interval}s`, 'middle', {
transform: `scale(1,-1), translate(0,20)`,
line(0, yHeight, xWidth, yHeight, { stroke: color }),
line(xWidth - 5, yHeight + 3, xWidth, yHeight, { stroke: color }),
line(xWidth - 5, yHeight - 3, xWidth, yHeight, { stroke: color }),
text(xWidth, yHeight + 15, `${interval}s`, 'middle', {
// transform: `scale(1,-1), translate(0,20)`,
fontSize: LABELFONTSIZE,
}),
];
......@@ -283,13 +284,13 @@ const axisX = (width: number, data: PlotData, interval: Interval) => {
axis.push(
text(
xWidth,
3,
yHeight - 3,
`${fmtDateNb(labelDate.getDate())}/${fmtDateNb(
labelDate.getMonth() + 1
)}/${labelDate.getFullYear()}`,
'middle',
{
transform: `scale(1,-1), translate(0,20)`,
// transform: `scale(1,-1), translate(0,20)`,
fontSize: LABELFONTSIZE,
}
)
......@@ -301,25 +302,25 @@ const axisX = (width: number, data: PlotData, interval: Interval) => {
// if (type === 'ground-quantity') {
const dist = getXInPixel(date.getTime(), unitMilli, minDateMilli);
axis.push(
line(dist, 0, dist, graphsize.height, {
line(dist, yHeight, dist, 0, {
stroke: '#d9d9d9',
})
);
// }
axis.push(line(dist, 0, dist, -2, { stroke: color }));
axis.push(line(dist, yHeight, dist, yHeight + 2, { stroke: color }));
// if to many labels, just display one of the two and place one of the four lower.
let disp = 'ok';
let translation = 20;
let translation = 0;
if (nbUnit > 25 && i % 4 != 0) {
translation = 25;
translation = 5;
}
if (nbUnit > 15 && i % 2 != 0) {
disp = 'none';
}
axis.push(
text(dist, -11, dateLabel(date, interval), 'middle', {
transform: `scale(1,-1), translate(0,${translation})`,
text(dist, yHeight + 11, dateLabel(date, interval), 'middle', {
transform: `translate(0,${translation})`,
fontSize: LABELFONTSIZE,
display: disp,
})
......@@ -381,15 +382,15 @@ const axisY = (
const yHeight = graphsize.height;
const axis = [
line(x, 0, x, yHeight, { stroke: color }),
line(x - 3, yHeight - 5, x, yHeight, { stroke: color }),
line(x + 3, yHeight - 5, x, yHeight, { stroke: color }),
line(x - 3, 5, x, 0, { stroke: color }),
line(x + 3, 5, x, 0, { stroke: color }),
text(
x,
yHeight,
-5,
`${getSelectedParameterList().map((p) => p.unit)[index]}`,
'middle',
{
transform: `scale(1,-1), translate(0,-${yHeight * 2 + 4})`,
// transform: `scale(1,-1), translate(0,-${yHeight * 2 + 4})`,
fontSize: LABELFONTSIZE,
fill: color,
}
......@@ -423,7 +424,7 @@ const axisY = (
axis.push(line(x, dist, x - 2, dist, { stroke: color }));
axis.push(
text(x - 5, dist + 2, labelText, 'end', {
transform: `scale(1,-1), translate(0,-${dist * 2})`,
// transform: `translate(0,-${dist * 2})`,
fontSize: LABELFONTSIZE,
})
);
......@@ -486,7 +487,7 @@ const multiplesYAxis = (data: PlotData) => {
*/
//
const getYInPixel = (value: number, yUnit: number, min: number) => {
return (value - min) * yUnit + innerPadding.bottom;
return graphsize.height - ((value - min) * yUnit + innerPadding.bottom);
};
/**
......@@ -647,10 +648,10 @@ const chartNorms = (
'end',
{
fill: `${chartInfo.color}`,
transform: `scale(1,-1), translate(0,-${
getYInPixel(n.value, chartInfo.yUnit, chartInfo.yMin) *
2
})`,
// transform: `scale(1,-1), translate(0,-${
// getYInPixel(n.value, chartInfo.yUnit, chartInfo.yMin) *
// 2
// })`,
fontSize: LABELFONTSIZE,
}
),
......@@ -902,7 +903,7 @@ const reallyPlot = (data: PlotData) => {
-${padding.top}
${graphsize.width + padding.left + padding.right}
${graphsize.height + padding.top + padding.bottom}`,
transform: 'scale(1,-1)',
// transform: 'scale(1,-1)',
})
);
};
......
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