1

I've been trying to figure this out for a day or two. I'm pretty sure I've typed the exact code from the tutorial I've been watching, but my x axis labels are numbers going from 0 to 1200 in increments of 100. They should be a list of dates provided by the hc.options.xAxis.catagories variable near the bottom of the code. It was my understanding creating this line would create the attribute 'catagories' and fill the x axis labels. I've tried hacking about in the javascript to work around, but to no avail. Can anyone see the issue?

import justpy as jp
import pandas as pd
from datetime import datetime
from pytz import utc

data=pd.read_csv('reviews.csv',parse_dates=['Timestamp'])
data['Day']=data['Timestamp'].dt.date 
day_average=data.groupby(['Day']).mean()


chart_def="""
{
    chart: {
        type: 'spline',
        inverted: false
    },
    title: {
        text: 'Atmosphere Temperature by Altitude'
    },
    subtitle: {
        text: 'According to the Standard Atmosphere Model'
    },
    xAxis: {
        reversed: false,
        title: {
            enabled: true,
            text: 'Altitude'
        },
        labels: {
            format: '{value} km'
        },
        accessibility: {
            rangeDescription: 'Range: 0 to 80 km.'
        },
        maxPadding: 0.05,
        showLastLabel: true
    },
    yAxis: {
        title: {
            text: 'Temperature'
        },
        labels: {
            format: '{value}°'
        },
        accessibility: {
            rangeDescription: 'Range: -90°C to 20°C.'
        },
        lineWidth: 2
    },
    legend: {
        enabled: false
    },
    tooltip: {
        headerFormat: '<b>{series.name}</b><br/>',
        pointFormat: '{point.x} km: {point.y}°C'
    },
    plotOptions: {
        spline: {
            marker: {
                enable: false
            }
        }
    },
    series: [{
        name: 'Temperature',
        data: [[0, 15], [10, -50], [20, -56.5], [30, -46.5], [40, -22.1],
            [50, -2.5], [60, -27.7], [70, -55.7], [80, -76.5]]
    }]
}
"""

def app():
    wp=jp.QuasarPage()

    h1=jp.QDiv(a=wp, text='Analysis of Course Reviews',classes='text-h3 text-center q-pa-md')
    p1=jp.QDiv(a=wp,text="These graphs represent course reviews analysis")
    hc=jp.HighCharts(a=wp, options=chart_def)
    hc.options.title.text='Average rating by Day'
    hc.options.xAxis.catagories = day_average.index
    hc.options.series[0].data=list(day_average['Rating'])
    


    return wp

jp.justpy(app)
  • Hi @Joe Mcsweeney, Does the title: Average rating by Day' work as expected? What is the result of: `day_average.index`? Live example with your code in pure JS: http://jsfiddle.net/BlackLabel/aLn49dxr/ – ppotaczek Aug 30 '22 at 09:28
  • 1
    Figured it out. I can't spell, 'categories' not 'catagories". FML – Joe Mcsweeney Sep 03 '22 at 15:43
  • @JoeMcsweeney could you please provide a sample csv file so that we might add this to our example in the justpy codebase and add an answer even if it's just a typo. This is a good example why asking questions via stackoverflow is better than adding issues or questions to justpy github immediately when a problem shows up see https://github.com/justpy-org/justpy/discussions/491 – Wolfgang Fahl Sep 05 '22 at 08:40

0 Answers0