Logo Search packages:      
Sourcecode: koffice version File versions

void KDChartParams::setDefaultAxesTypes (  ) 

Set the default axis types for all the axes the user might activate for this chart:

  • Pie charts by default have no axes at all
  • Bar/Line/Area charts may have up to 8 axes (up to 2 at each side of the chart)
  • charts representing 3-dimensional data may have up to 12 axes
Note:
This function also specifies the default way how to calculate the axis labels: abscissa starts with zero and counts by 1, ordinate is calculating the labels automatically based upon the values found in the associated dataset(s).

Definition at line 1837 of file KDChartParams.cpp.

References KDChartAxisParams::AXIS_LABELS_AUTO_LIMIT, changed(), chartType(), KDCHART_MAX_AXES, setAxisLabelsFont(), setAxisLabelsTouchEdges(), setAxisLabelsVisible(), setAxisLabelTextParams(), setAxisShowGrid(), setAxisType(), and setPolarRotateCircularLabels().

Referenced by KDChartParams(), and setPrintDataValues().

{
    // reset types of all axes
    uint i = 0;
    for ( i = 0; i < KDCHART_MAX_AXES; ++i )
        setAxisType( i, KDChartAxisParams::AxisTypeUnknown );

    // Note that abscissa axes should start labeling at the very
    // first position and end at the last position when drawing
    // area charts.
    // Bar charts and line charts look better with their abscissa labels
    // in the respective middle positions below each bar (or point, resp.)
    for ( i = KDChartAxisParams::AxisPosSTART;
            i <= KDChartAxisParams::AxisPosEND; ++i )
        switch ( i ) {
            // abscissa axes:
            case KDChartAxisParams::AxisPosBottom:
            case KDChartAxisParams::AxisPosTop:
            case KDChartAxisParams::AxisPosBottom2:
            case KDChartAxisParams::AxisPosTop2:
                setAxisLabelsTouchEdges( i, Area == chartType() );
                break;
                // ordinate axes:
            case KDChartAxisParams::AxisPosLeft:
            case KDChartAxisParams::AxisPosRight:
            case KDChartAxisParams::AxisPosLeft2:
            case KDChartAxisParams::AxisPosRight2:
                setAxisLabelsTouchEdges( i, true ); //Polar != chartType() );
                break;
                // additional axes for charts representing 3-dimensional data:
            case KDChartAxisParams::AxisPosLowerRightEdge:
            case KDChartAxisParams::AxisPosLowerLeftEdge:
            case KDChartAxisParams::AxisPosLowerRightEdge2:
            case KDChartAxisParams::AxisPosLowerLeftEdge2:
                setAxisLabelsTouchEdges( i, false );
                break;
            default: {
                         qDebug( "IMPLEMENTATION ERROR: axis type missing in KDChartParams::setDefaultAxesTypes()" );
                         Q_ASSERT( !this );
                     }
        }

    // set default axis types according to chart type
    switch ( chartType() ) {
        case NoType:
            break;
        case Bar:
        case Line:
        case Area:
            // default axes
            setAxisType( KDChartAxisParams::AxisPosBottom,
                    KDChartAxisParams::AxisTypeEAST );
            setAxisShowGrid( KDChartAxisParams::AxisPosBottom,
                    true );
            setAxisType( KDChartAxisParams::AxisPosLeft,
                    KDChartAxisParams::AxisTypeNORTH );
            setAxisShowGrid( KDChartAxisParams::AxisPosLeft,
                    true );
            // 'other side' axes
            setAxisType( KDChartAxisParams::AxisPosTop,
                    KDChartAxisParams::AxisTypeEAST );
            setAxisType( KDChartAxisParams::AxisPosRight,
                    KDChartAxisParams::AxisTypeNORTH );
            // additional, 2nd axes
            setAxisType( KDChartAxisParams::AxisPosBottom2,
                    KDChartAxisParams::AxisTypeEAST );
            setAxisType( KDChartAxisParams::AxisPosLeft2,
                    KDChartAxisParams::AxisTypeNORTH );
            // additional, 2nd axes for 'other' sides
            setAxisType( KDChartAxisParams::AxisPosTop2,
                    KDChartAxisParams::AxisTypeEAST );
            setAxisType( KDChartAxisParams::AxisPosRight2,
                    KDChartAxisParams::AxisTypeNORTH );

            // Specify default numbering information
            // for all 'non-ordinate' axes (this are the X axes):
            //
            // axisSteadyValueCalc flag is set to false
            // Start value 1
            // End value   following the number of entries
            //             in the associated dataset(s)
            // Delta value 1.0
            // and dont show any Digits behind the comma.
            setAxisLabelTextParams( KDChartAxisParams::AxisPosBottom, false,
                    1.0,
                    KDChartAxisParams::AXIS_LABELS_AUTO_LIMIT,
                    1.0, 0 );
            setAxisLabelTextParams( KDChartAxisParams::AxisPosTop, false,
                    1.0,
                    KDChartAxisParams::AXIS_LABELS_AUTO_LIMIT,
                    1.0, 0 );
            setAxisLabelTextParams( KDChartAxisParams::AxisPosBottom2, false,
                    1.0,
                    KDChartAxisParams::AXIS_LABELS_AUTO_LIMIT,
                    1.0, 0 );
            setAxisLabelTextParams( KDChartAxisParams::AxisPosTop2, false,
                    1.0,
                    KDChartAxisParams::AXIS_LABELS_AUTO_LIMIT,
                    1.0, 0 );

            // no need to specify numbering information for
            // the ordinate-axes since the default auto-calc
            // feature is fine for here.

            break;

            // Code for charts representing 3-dimensional data.

            /*

            //   ( not active since there are no such charts yet )

            case KDChartParams::BarMatrix:
            // default axes
            setAxisType( KDChartAxisParams::AxisPosBottom,
            KDChartAxisParams::AxisTypeEAST );
            setAxisType( KDChartAxisParams::AxisPosLowerRightEdge,
            KDChartAxisParams::AxisTypeNORTH );
            setAxisType( KDChartAxisParams::AxisPosLeft,
            KDChartAxisParams::AxisTypeUP );
            // 'other side' axes
            setAxisType( KDChartAxisParams::AxisPosTop,
            KDChartAxisParams::AxisTypeEAST );
            setAxisType( KDChartAxisParams::AxisPosLowerLeftEdge,
            KDChartAxisParams::AxisTypeNORTH );
            setAxisType( KDChartAxisParams::AxisPosRight,
            KDChartAxisParams::AxisTypeUP );
            // additional, 2nd axes
            setAxisType( KDChartAxisParams::AxisPosBottom2,
            KDChartAxisParams::AxisTypeEAST );
            setAxisType( KDChartAxisParams::AxisPosLowerRightEdge2,
            KDChartAxisParams::AxisTypeNORTH );
            setAxisType( KDChartAxisParams::AxisPosLeft2,
            KDChartAxisParams::AxisTypeUP );
            // additional, 2nd axes for 'other' sides
            setAxisType( KDChartAxisParams::AxisPosTop2,
            KDChartAxisParams::AxisTypeEAST );
            setAxisType( KDChartAxisParams::AxisPosLowerLeftEdge2,
            KDChartAxisParams::AxisTypeNORTH );
            setAxisType( KDChartAxisParams::AxisPosRight2,
            KDChartAxisParams::AxisTypeUP );

            // Specify default numbering information
            // for all 'non-ordinate' axes (this are the X and the Y axes):
            // Start vaule 1
            // End value   following the number of entries
            //             in the associated dataset(s)
            // Delta value 1.0
            // and don't show any Digits behind the comma.
            setAxisLabelTextParams( KDChartAxisParams::AxisPosBottom,  false,
            1.0, AXIS_LABELS_AUTO_LIMIT, 1.0, 0 );
            setAxisLabelTextParams( KDChartAxisParams::AxisPosTop,     false,
            1.0, AXIS_LABELS_AUTO_LIMIT, 1.0, 0 );
            setAxisLabelTextParams( KDChartAxisParams::AxisPosLowerRightEdge,
            false,
            1.0, AXIS_LABELS_AUTO_LIMIT, 1.0, 0 );
            setAxisLabelTextParams( KDChartAxisParams::AxisPosLowerLeftEdge,
            false,
            1.0, AXIS_LABELS_AUTO_LIMIT, 1.0, 0 );
            setAxisLabelTextParams( KDChartAxisParams::AxisPosBottom2, false,
            1.0, AXIS_LABELS_AUTO_LIMIT, 1.0, 0 );
            setAxisLabelTextParams( KDChartAxisParams::AxisPosTop2,    false,
            1.0, AXIS_LABELS_AUTO_LIMIT, 1.0, 0 );
            setAxisLabelTextParams(KDChartAxisParams::AxisPosLowerRightEdge2,
            false,
            1.0, AXIS_LABELS_AUTO_LIMIT, 1.0, 0 );
            setAxisLabelTextParams( KDChartAxisParams::AxisPosLowerLeftEdge2,
            false,
            1.0, AXIS_LABELS_AUTO_LIMIT, 1.0, 0 );

            false,
            1.0, AXIS_LABELS_AUTO_LIMIT, 1.0, 0 );

            // no need to specify numbering information for
            // the ordinate-axes since the default auto-calc
            // feature is fine for here.

            break;
            */

        case KDChartParams::Pie:
        case KDChartParams::Ring:
            // by default there are no axes defined for pie and ring charts
            break;
        case KDChartParams::Polar:
            setAxisType( KDChartAxisParams::AxisPosSaggital,
                    KDChartAxisParams::AxisTypeEAST );
            setAxisType( KDChartAxisParams::AxisPosCircular,
                    KDChartAxisParams::AxisTypeNORTH );
            setAxisLabelsVisible( KDChartAxisParams::AxisPosSaggital, true );
            setAxisLabelsFont( KDChartAxisParams::AxisPosSaggital,
                               QFont( "helvetica", 1, QFont::Bold ),
                               -40,
                               Qt::darkBlue );
            setAxisLabelsVisible( KDChartAxisParams::AxisPosCircular, true );
            setAxisLabelsFont( KDChartAxisParams::AxisPosCircular,
                               QFont( "helvetica", 1, QFont::Bold ),
                               -29,
                               Qt::darkBlue );
            setPolarRotateCircularLabels( false );
            break;
        default: {
                     qDebug( "IMPLEMENTATION ERROR: type missing in KDChartParams::setDefaultAxesTypes()" );
                     Q_ASSERT( !this );
                 }
    }

    emit changed();
}


Generated by  Doxygen 1.6.0   Back to index