我正在尝试使用来自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)发布于 2021-12-06 16:59:42
我发现这是第一个加载可访问性模块选项的示例。你把这个剧本加入剧本了吗?
https://code.highcharts.com/modules/accessibility.js
发布于 2022-01-06 19:55:39
通过从代码中删除以下行,您将能够获得显示饼图:
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,因此,您的脚本应该如下所示:
import justpy as jp
chart_options = """{
chart: {
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)https://stackoverflow.com/questions/70180924
复制相似问题