饼图不弹出 HighCharts
Pie Chart Not Popping Up HighCharts
我正在尝试制作一个饼图来显示 python 课程的评分。但是每次我尝试 运行 它时,饼图不会弹出,只会弹出标题。我正在使用 HighCharts 创建饼图,它也应该是交互式的。这就是我用来创建饼图的内容。我也没有收到任何错误消息。请帮助我。
下面是我的代码:
import justpy as jp
import justpy as jp
import pandas as pa
from datetime import datetime
from pytz import utc
data = pa.read_csv("reviews.csv", parse_dates=['Timestamp'])
share = data.groupby(['Course Name'])['Rating'].count()
chart_def = """
{
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: 'pie'
},
title: {
text: 'Browser market shares in January, 2018'
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
},
accessibility: {
point: {
valueSuffix: '%'
}
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
format: '<b>{point.name}</b>: {point.percentage:.1f} %'
}
}
},
series: [{
name: 'Brands',
colorByPoint: true,
data: [{
name: 'Chrome',
y: 61.41,
sliced: true,
selected: true
}, {
name: 'Internet Explorer',
y: 11.84
}, {
name: 'Firefox',
y: 10.85
}, {
name: 'Edge',
y: 4.67
}, {
name: 'Safari',
y: 4.18
}, {
name: 'Sogou Explorer',
y: 1.64
}, {
name: 'Opera',
y: 1.6
}, {
name: 'QQ',
y: 1.2
}, {
name: 'Other',
y: 2.61
}]
}]
}
"""
def app():
wp = jp.QuasarPage()
h1 = jp.QDiv(a = wp, text = "Analaysis of Course Reviews", classes='text-h3 text-center q-pa-md')
p1 = jp.QDiv(a = wp, text = "These graphs represent course review analaysis")
hc = jp.HighCharts(a= wp, options = chart_def)
hc_data = [{"name":v1, "y":v2} for v1, v2 in zip(share.index, share)]
hc.options.series[0].data = hc_data
return wp
jp.justpy(app)
我遇到了同样的问题。
我通过删除(或注释掉)下面的 2 行代码修复了它,它们设置了“plotBackgroundColor”和“plotBorderWidth" 属性为空:
chart_def = """
{
chart: {
//plotBackgroundColor: null, --> remove or comment out this line
//plotBorderWidth: null, --> remove or comment out this line
plotShadow: false,
type: 'pie'
},
(...)
我正在尝试制作一个饼图来显示 python 课程的评分。但是每次我尝试 运行 它时,饼图不会弹出,只会弹出标题。我正在使用 HighCharts 创建饼图,它也应该是交互式的。这就是我用来创建饼图的内容。我也没有收到任何错误消息。请帮助我。
下面是我的代码:
import justpy as jp
import justpy as jp
import pandas as pa
from datetime import datetime
from pytz import utc
data = pa.read_csv("reviews.csv", parse_dates=['Timestamp'])
share = data.groupby(['Course Name'])['Rating'].count()
chart_def = """
{
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: 'pie'
},
title: {
text: 'Browser market shares in January, 2018'
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
},
accessibility: {
point: {
valueSuffix: '%'
}
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
format: '<b>{point.name}</b>: {point.percentage:.1f} %'
}
}
},
series: [{
name: 'Brands',
colorByPoint: true,
data: [{
name: 'Chrome',
y: 61.41,
sliced: true,
selected: true
}, {
name: 'Internet Explorer',
y: 11.84
}, {
name: 'Firefox',
y: 10.85
}, {
name: 'Edge',
y: 4.67
}, {
name: 'Safari',
y: 4.18
}, {
name: 'Sogou Explorer',
y: 1.64
}, {
name: 'Opera',
y: 1.6
}, {
name: 'QQ',
y: 1.2
}, {
name: 'Other',
y: 2.61
}]
}]
}
"""
def app():
wp = jp.QuasarPage()
h1 = jp.QDiv(a = wp, text = "Analaysis of Course Reviews", classes='text-h3 text-center q-pa-md')
p1 = jp.QDiv(a = wp, text = "These graphs represent course review analaysis")
hc = jp.HighCharts(a= wp, options = chart_def)
hc_data = [{"name":v1, "y":v2} for v1, v2 in zip(share.index, share)]
hc.options.series[0].data = hc_data
return wp
jp.justpy(app)
我遇到了同样的问题。
我通过删除(或注释掉)下面的 2 行代码修复了它,它们设置了“plotBackgroundColor”和“plotBorderWidth" 属性为空:
chart_def = """
{
chart: {
//plotBackgroundColor: null, --> remove or comment out this line
//plotBorderWidth: null, --> remove or comment out this line
plotShadow: false,
type: 'pie'
},
(...)