help(pie)
говорит:
*autopct*: [ *None* | format string | format function ]
If not *None*, is a string or function used to label the
wedges with their numeric value. The label will be placed inside
the wedge. If it is a format string, the label will be ``fmt%pct``.
If it is a function, it will be called.
, чтобы вы могли вернуть проценты в исходные значения, умножив их на общий размер пирога и разделив на 100:
figure(1, figsize=(6,6))
ax = axes([0.1, 0.1, 0.8, 0.8])
labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
fracs = [15, 30, 45, 10]
total = sum(fracs)
explode=(0, 0.05, 0, 0)
pie(fracs, explode=explode, labels=labels,
autopct=lambda(p): '{:.0f}'.format(p * total / 100),
shadow=True, startangle=90)
show()
[/g0]
Есть много способов сделать это, я предполагаю, что вам нужно опросить сервер после определенного интервала и обновить ваш экран, вы можете сделать что-то вроде этого:
Опрос через определенный интервал времени
constructor(props) {
super(props);
this.state = {
tableHead: ['', 'Head1', 'Head2', 'Head3'],
tableTitle: ['Title', 'Title2', 'Title3', 'Title4'],
tableData: [ ],
keepPolling: true
}
componentWillMount()
{
pollAfter(60 * 1000, ()=>{
// get your data from the server here
}).then((response)=>{
// and set state here like this
this.setState({
tableData : response
});
})
}
pollAfter(intervalDuration, fn) {
const asyncTimeout = () => setTimeout(() => {
this.pollAfter(intervalDuration, fn);
}, intervalDuration);
const assignNextInterval = () => {
if (!this.keepPolling) {
this.stopPolling();
return;
}
this.interval = asyncTimeout();
};
Promise.resolve(promise)
.then(assignNextInterval)
.catch(assignNextInterval);
}