Exemplo n.º 1
0
void PieChart::plot()
{
    chart->removeAllSeries();

    chart->setAnimationOptions( (QChart::AnimationOption)ui->animationComboBox->currentIndex() );
    ui->chartView->setRenderHint(QPainter::Antialiasing, ui->antialiasingCheckBox->isChecked());

    //create series
    QPieSeries * series = new QPieSeries();
//    series->setLabelsVisible();

    series->setHorizontalPosition( ui->hPosSpinBox->value() );
    series->setVerticalPosition( ui->vPosSpinBox->value() );
    series->setPieSize( ui->sizeFactorSpinBox->value() );
    series->setPieStartAngle( ui->startAngleSpinBox->value() );
    series->setPieEndAngle( ui->endAngleSpinBox->value() );
    series->setHoleSize( ui->holeSizeSpinBox->value() );

    foreach( pie_chart_plot_item_t sliceItem, items )
    {
        FlexiPieSlice * slice = new FlexiPieSlice( sliceItem.name, sliceItem.value );
        slice->setExplodeOnHover( ui->explodeSliceCheckBox->isChecked() );
        if(sliceItem.colorIsSet)
        {
            //slice->setPen(QPen(sliceItem.color, 2));
            slice->setBrush(sliceItem.color);
        }
        *series << slice;
    }
Exemplo n.º 2
0
//! [6]
void Widget::updateRotation()
{
    for (int i = 0; i < m_donuts.count(); i++) {
        QPieSeries *donut = m_donuts.at(i);
        qreal phaseShift =  -50 + QRandomGenerator::global()->bounded(100);
        donut->setPieStartAngle(donut->pieStartAngle() + phaseShift);
        donut->setPieEndAngle(donut->pieEndAngle() + phaseShift);
    }
}