Excel-Writer-XLSX

 view release on metacpan or  search on metacpan

lib/Excel/Writer/XLSX/Chart/Scatter.pm  view on Meta::CPAN


    $self->xml_start_tag( 'c:plotArea' );

    # Write the c:layout element.
    $self->_write_layout( $self->{_plotarea}->{_layout}, 'plot' );

    # Write the subclass chart type elements for primary and secondary axes.
    $self->_write_chart_type( primary_axes => 1 );
    $self->_write_chart_type( primary_axes => 0 );

    # Write c:catAx and c:valAx elements for series using primary axes.
    $self->_write_cat_val_axis(
        x_axis   => $self->{_x_axis},
        y_axis   => $self->{_y_axis},
        axis_ids => $self->{_axis_ids},
        position => 'b',
    );

    my $tmp = $self->{_horiz_val_axis};
    $self->{_horiz_val_axis} = 1;
    $self->_write_val_axis(
        x_axis   => $self->{_x_axis},
        y_axis   => $self->{_y_axis},
        axis_ids => $self->{_axis_ids},
        position => 'l',
    );
    $self->{_horiz_val_axis} = $tmp;

    # Write c:valAx and c:catAx elements for series using secondary axes.
    $self->_write_cat_val_axis(
        x_axis   => $self->{_x2_axis},
        y_axis   => $self->{_y2_axis},
        axis_ids => $self->{_axis2_ids},
        position => 'b',
    );
    $self->{_horiz_val_axis} = 1;
    $self->_write_val_axis(
        x_axis   => $self->{_x2_axis},
        y_axis   => $self->{_y2_axis},
        axis_ids => $self->{_axis2_ids},
        position => 'l',
    );

    # Write the c:spPr element for the plotarea formatting.
    $self->_write_sp_pr( $self->{_plotarea} );

    $self->xml_end_tag( 'c:plotArea' );
}


##############################################################################
#
# _write_x_val()
#
# Write the <c:xVal> element.
#
sub _write_x_val {

    my $self    = shift;
    my $series  = shift;
    my $formula = $series->{_categories};
    my $data_id = $series->{_cat_data_id};
    my $data    = $self->{_formula_data}->[$data_id];

    $self->xml_start_tag( 'c:xVal' );

    # Check the type of cached data.
    my $type = $self->_get_data_type( $data );

    # TODO. Can a scatter plot have non-numeric data.

    if ( $type eq 'str' ) {

        # Write the c:numRef element.
        $self->_write_str_ref( $formula, $data, $type );
    }
    else {

        # Write the c:numRef element.
        $self->_write_num_ref( $formula, $data, $type );
    }

    $self->xml_end_tag( 'c:xVal' );
}


##############################################################################
#
# _write_y_val()
#
# Write the <c:yVal> element.
#
sub _write_y_val {

    my $self    = shift;
    my $series  = shift;
    my $formula = $series->{_values};
    my $data_id = $series->{_val_data_id};
    my $data    = $self->{_formula_data}->[$data_id];

    $self->xml_start_tag( 'c:yVal' );

    # Unlike Cat axes data should only be numeric.

    # Write the c:numRef element.
    $self->_write_num_ref( $formula, $data, 'num' );

    $self->xml_end_tag( 'c:yVal' );
}


##############################################################################
#
# _write_scatter_style()
#
# Write the <c:scatterStyle> element.
#
sub _write_scatter_style {

    my $self = shift;
    my $val  = shift;

    my @attributes = ( 'val' => $val );

    $self->xml_empty_tag( 'c:scatterStyle', @attributes );
}


##############################################################################
#
# _modify_series_formatting()
#
# Add default formatting to the series data unless it has already been
# specified by the user.
#
sub _modify_series_formatting {

    my $self    = shift;
    my $subtype = $self->{_subtype};

    # The default scatter style "markers only" requires a line type.
    if ( $subtype eq 'marker_only' ) {

        # Go through each series and define default values.
        for my $series ( @{ $self->{_series} } ) {

            # Set a line type unless there is already a user defined type.
            if ( !$series->{_line}->{_defined} ) {
                $series->{_line} = {
                    width    => 2.25,
                    none     => 1,
                    _defined => 1,
                };
            }
        }
    }
}


##############################################################################
#
# _write_d_pt_point()
#
# Write an individual <c:dPt> element. Override the parent method to add
# markers.
#



( run in 0.624 second using v1.01-cache-2.11-cpan-39bf76dae61 )