~pvsr/weather

db8a58a0748dafd2d8ae69d2c0846e6f3e72577e — Peter Rice 8 months ago 40b1727 master
Reduce temperature graph from 48 to 36 hours
4 files changed, 9 insertions(+), 4 deletions(-)

M location.py
M static/main.css
M templates/chart.js
M weather.py
M location.py => location.py +4 -1
@@ 46,7 46,10 @@ def fetch_json(url: str, default: str):
        with open(default, 'r') as local_data:
            return json.load(local_data)
    else:
        return REQUEST_CACHE.get(url).json()
        # print(f"requesting {url}")
        resp = REQUEST_CACHE.get(url)
        # print(resp)
        return resp.json()


def read_locations() -> Mapping[str, Location]:

M static/main.css => static/main.css +1 -0
@@ 127,6 127,7 @@ a:active {
.ct-label {
  color: var(--fg1);
  font-size: 1em;
  /* TODO prevent wrapping? */
}

@media screen and (max-width: 768px) {

M templates/chart.js => templates/chart.js +3 -2
@@ 18,14 18,15 @@ new Chartist.Line('.ct-chart', data, {
      {
        showPoint: false,
        axisX: {
          labelInterpolationFnc: label(8),
          // TODO maybe derive from number of data points
          labelInterpolationFnc: label(6),
        }
      },
    ],
    ['screen and (min-width: 768px)',
      {
        axisX: {
          labelInterpolationFnc: label(4),
          labelInterpolationFnc: label(3),
        }
      },
    ]

M weather.py => weather.py +1 -1
@@ 44,7 44,7 @@ def weather(key: Optional[str]):
        current_location=location,
        available_locations=locations.keys(),
        forecast=forecasts(location.forecast()),
        hourly=forecasts(location.hourly())[0:48],
        hourly=forecasts(location.hourly())[0:36],
        alerts=alerts,
    )