Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jp bar how to order along the y-axis by date #27

Open
jbauernberger opened this issue Jan 5, 2021 · 0 comments
Open

jp bar how to order along the y-axis by date #27

jbauernberger opened this issue Jan 5, 2021 · 0 comments

Comments

@jbauernberger
Copy link

jbauernberger commented Jan 5, 2021

Hi,

sorry if this is a silly question and appreciate your patience.

I'm calling jp with the json input shown further below. For some reason the "date" from the json across the x axis is not showing up in correct order which I expected (e.g., as in the same sequence as the input json). The data in each column is correct (the date matches the new_cases), but I'm having troubles making them appear on the y axes in ascending order by date (e.g. exactly as they are in the input.json)

Here is the output produced by jp:

screensho_jp_terminal

Here is the input json:

{
  "continent": "Europe",
  "location": "Austria",
  "population": 9006400,
  "population_density": 106.749,
  "median_age": 44.4,
  "aged_65_older": 19.202,
  "aged_70_older": 13.748,
  "gdp_per_capita": 45436.686,
  "cardiovasc_death_rate": 145.183,
  "diabetes_prevalence": 6.35,
  "handwashing_facilities": null,
  "hospital_beds_per_thousand": 7.37,
  "life_expectancy": 81.54,
  "human_development_index": 0.908,
  "day1": {
    "date": "2020-12-29",
    "total_cases": 355352,
    "new_cases": 1868,
    "new_cases_smoothed": 1875.143,
    "total_deaths": 6059,
    "new_deaths": 128,
    "new_deaths_smoothed": 74.143,
    "total_cases_per_million": 39455.498,
    "new_cases_per_million": 207.408,
    "new_cases_smoothed_per_million": 208.201,
    "total_deaths_per_million": 672.744,
    "new_deaths_per_million": 14.212,
    "new_deaths_smoothed_per_million": 8.232,
    "new_tests": 15563,
    "total_tests": 3794046,
    "total_tests_per_thousand": 421.261,
    "new_tests_per_thousand": 1.728,
    "new_tests_smoothed": 21479,
    "new_tests_smoothed_per_thousand": 2.385,
    "positive_rate": 0.087,
    "tests_per_case": 11.5,
    "tests_units": "tests performed"
  },
  "day2": {
    "date": "2020-12-30",
    "total_cases": 357902,
    "new_cases": 2550,
    "new_cases_smoothed": 1935,
    "total_deaths": 6149,
    "new_deaths": 90,
    "new_deaths_smoothed": 70.714,
    "total_cases_per_million": 39738.63,
    "new_cases_per_million": 283.132,
    "new_cases_smoothed_per_million": 214.847,
    "total_deaths_per_million": 682.737,
    "new_deaths_per_million": 9.993,
    "new_deaths_smoothed_per_million": 7.852,
    "new_tests": 16085,
    "total_tests": 3810131,
    "total_tests_per_thousand": 423.047,
    "new_tests_per_thousand": 1.786,
    "new_tests_smoothed": 18285,
    "new_tests_smoothed_per_thousand": 2.03,
    "positive_rate": 0.106,
    "tests_per_case": 9.4,
    "tests_units": "tests performed",
    "total_vaccinations": 6000,
    "total_vaccinations_per_hundred": 0.07
  },
  "day3": {
    "date": "2020-12-31",
    "total_cases": 360815,
    "new_cases": 2913,
    "new_cases_smoothed": 1944.429,
    "total_deaths": 6222,
    "new_deaths": 73,
    "new_deaths_smoothed": 68.143,
    "total_cases_per_million": 40062.067,
    "new_cases_per_million": 323.437,
    "new_cases_smoothed_per_million": 215.894,
    "total_deaths_per_million": 690.842,
    "new_deaths_per_million": 8.105,
    "new_deaths_smoothed_per_million": 7.566,
    "new_tests": 26789,
    "total_tests": 3836920,
    "total_tests_per_thousand": 426.021,
    "new_tests_per_thousand": 2.974,
    "new_tests_smoothed": 17948,
    "new_tests_smoothed_per_thousand": 1.993,
    "positive_rate": 0.108,
    "tests_per_case": 9.2,
    "tests_units": "tests performed"
  },
  "day4": {
    "date": "2021-01-01",
    "total_cases": 362911,
    "new_cases": 2096,
    "new_cases_smoothed": 1979.429,
    "total_deaths": 6261,
    "new_deaths": 39,
    "new_deaths_smoothed": 68.286,
    "total_cases_per_million": 40294.79,
    "new_cases_per_million": 232.723,
    "new_cases_smoothed_per_million": 219.78,
    "total_deaths_per_million": 695.172,
    "new_deaths_per_million": 4.33,
    "new_deaths_smoothed_per_million": 7.582,
    "new_tests": 20462,
    "total_tests": 3857382,
    "total_tests_per_thousand": 428.293,
    "new_tests_per_thousand": 2.272,
    "new_tests_smoothed": 17783,
    "new_tests_smoothed_per_thousand": 1.974,
    "positive_rate": 0.111,
    "tests_per_case": 9,
    "tests_units": "tests performed"
  },
  "day5": {
    "date": "2021-01-02",
    "total_cases": 364302,
    "new_cases": 1391,
    "new_cases_smoothed": 1974,
    "total_deaths": 6275,
    "new_deaths": 14,
    "new_deaths_smoothed": 61.714,
    "total_cases_per_million": 40449.236,
    "new_cases_per_million": 154.446,
    "new_cases_smoothed_per_million": 219.177,
    "total_deaths_per_million": 696.727,
    "new_deaths_per_million": 1.554,
    "new_deaths_smoothed_per_million": 6.852
  },
  "day6": {
    "date": "2021-01-03",
    "total_cases": 365768,
    "new_cases": 1466,
    "new_cases_smoothed": 1982.286,
    "total_deaths": 6324,
    "new_deaths": 49,
    "new_deaths_smoothed": 63.286,
    "total_cases_per_million": 40612.009,
    "new_cases_per_million": 162.773,
    "new_cases_smoothed_per_million": 220.097,
    "total_deaths_per_million": 702.167,
    "new_deaths_per_million": 5.441,
    "new_deaths_smoothed_per_million": 7.027
  },
  "day7": {
    "date": "2021-01-04",
    "total_cases": 367410,
    "new_cases": 1642,
    "new_cases_smoothed": 1989.429,
    "total_deaths": 6357,
    "new_deaths": 33,
    "new_deaths_smoothed": 60.857,
    "total_cases_per_million": 40794.324,
    "new_cases_per_million": 182.315,
    "new_cases_smoothed_per_million": 220.891,
    "total_deaths_per_million": 705.831,
    "new_deaths_per_million": 3.664,
    "new_deaths_smoothed_per_million": 6.757
  }
}

And this is how the input json is processed with jp (it needs the input.json as it's only argument)

#!/bin/bash

if [ -z "$1" ]; then
  echo "Usage $0 input.json"
  exit 1
fi

corpus_tmp=~/.cache/covid_status/tmp/
mkdir -p $corpus_tmp

declare -r jp_chart_txt=`mktemp --suffix=.txt $corpus_tmp/covid_status_jp.XXXXXXXXX` || {
      echo "eror mktemp --suffix=.txt $corpus_tmp/covid_status_jp.XXXXXXXXX returned $?: $!" >&2; exit 1
  }

## date on x axis will cause the order get messed up. 
## FIXME!!
< "$@" ~/src/go/bin/jp -xy '..[date,new_cases]' -type bar -canvas full-escape &> $jp_chart_txt || {
  echo "jp failed ($?) - Sorry no chart :(" &>> $jp_chart_txt
  exit 1
}

less -X $jp_chart_txt
rm -f $jp_chart_txt
exit 0

thanks

edit: updated/corrected the input.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant