我正在尝试在 justpy中使用来自www.highcharts.com的饼图。
页面加载但图表未呈现。
我使用了这个来源的代码: https ://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/demo/pie-basic
我简化了代码以缩小问题范围:
import justpy as jp
chart_options = """{
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="Testing Pie chart",
classes="text-h3 text-center q-py-xl q-px-xl")
hc = jp.HighCharts(a=wp, options=chart_options)
return wp
jp.justpy(app)
我试图在不同的浏览器中打开它。我试图重新启动服务器,ide。来自 highcharts.com 的大多数图表都在工作(样条、区域样条、流图)。但是,我在折线图上遇到了同样的问题:https ://www.highcharts.com/docs/chart-and-series-types/line-chart 。
更新。为样条图添加工作示例:
import justpy as jp
chart_options = """{
chart: {
type: 'spline',
inverted: true
},
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="Testing Pie chart",
classes="text-h3 text-center q-py-xl q-px-xl")
hc = jp.HighCharts(a=wp, options=chart_options)
return wp
jp.justpy(app)