@@ -48,15 +48,17 @@ void drawChart(Element svg, HTMLDivElement toolTip, HTMLDivElement chartSubText,
4848 final drawingHeight = height - padding;
4949 final drawingWidth = width - 2 * padding;
5050
51- final lastDay = data.last.date;
52- final firstDay = data.first.date;
53- final xAxisSpan = lastDay.difference (firstDay);
51+ final lastDate = data.last.date;
52+ final firstDate = data.first.date;
53+ final firstDay = firstDate.copyWith (day: firstDate.day - 7 );
54+
55+ final xAxisSpan = lastDate.difference (firstDate);
5456 final maxDownloads = data.fold <int >(0 , (a, b) => max <int >(a, b.downloads));
5557
5658 final toolTipOffsetFromMouse = 15 ;
5759
5860 (double , double ) computeCoordinates (DateTime date, int downloads) {
59- final duration = date.difference (firstDay );
61+ final duration = date.difference (firstDate );
6062 final x = padding +
6163 drawingWidth * duration.inMilliseconds / xAxisSpan.inMilliseconds;
6264 final y = height - drawingHeight * (downloads / maxDownloads);
@@ -83,8 +85,7 @@ void drawChart(Element svg, HTMLDivElement toolTip, HTMLDivElement chartSubText,
8385
8486 // Render chart
8587
86- chartSubText.text = '${formatDate (firstDay )} - ${formatDate (lastDay )}' ;
87-
88+ chartSubText.text = '${formatDate (firstDay )} - ${formatDate (lastDate )}' ;
8889 final chart = SVGGElement ();
8990 final frame = SVGRectElement ();
9091 frame.setAttribute ('height' , '$height ' );
@@ -142,7 +143,7 @@ void drawChart(Element svg, HTMLDivElement toolTip, HTMLDivElement chartSubText,
142143 lowerBoundBy< ({DateTime date, int downloads}), double > (
143144 data,
144145 (e) =>
145- e.date.difference (firstDay ).inMilliseconds /
146+ e.date.difference (firstDate ).inMilliseconds /
146147 xAxisSpan.inMilliseconds,
147148 (a, b) => a.compareTo (b),
148149 s);
@@ -154,17 +155,18 @@ void drawChart(Element svg, HTMLDivElement toolTip, HTMLDivElement chartSubText,
154155 sparklineCursor.setAttribute ('transform' , 'translate(${coords .$1 }, 0)' );
155156 toolTip.text = '${formatWithThousandSeperators (selectedDay .downloads )}' ;
156157
157- final startDate = selectedDay.date.subtract (Duration (days: 7 ));
158+ final startDay = selectedDay.date.subtract (Duration (days: 7 ));
158159 chartSubText.text =
159- '${formatDate (startDate )} - ${formatDate (selectedDay .date )}' ;
160+ '${formatDate (startDay )} - ${formatDate (selectedDay .date )}' ;
160161
161162 lastSelectedDay = selectedDay.date;
162163 });
163164
164165 void erase (_) {
165166 sparklineCursor.setAttribute ('style' , 'opacity:0' );
166167 toolTip.setAttribute ('style' , 'opacity:0;position:absolute;' );
167- chartSubText.text = '${formatDate (firstDay )} - ${formatDate (lastDay )}' ;
168+
169+ chartSubText.text = '${formatDate (firstDay )} - ${formatDate (lastDate )}' ;
168170 }
169171
170172 erase (1 );
0 commit comments