| 1 | =begin comment | ||
| 2 | |||
| 3 | Copyright (c) 2026 Aspose.Cells Cloud | ||
| 4 | Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 5 | of this software and associated documentation files (the "Software"), to deal | ||
| 6 | in the Software without restriction, including without limitation the rights | ||
| 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 8 | copies of the Software, and to permit persons to whom the Software is | ||
| 9 | furnished to do so, subject to the following conditions: | ||
| 10 | |||
| 11 | The above copyright notice and this permission notice shall be included in all | ||
| 12 | copies or substantial portions of the Software. | ||
| 13 | |||
| 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 20 | SOFTWARE. | ||
| 21 | |||
| 22 | =end comment | ||
| 23 | |||
| 24 | =cut | ||
| 25 | |||
| 26 | package AsposeCellsCloud::Object::ErrorBar; | ||
| 27 | |||
| 28 | require 5.6.0; | ||
| 29 | use strict; | ||
| 30 | use warnings; | ||
| 31 | use utf8; | ||
| 32 | use JSON qw(decode_json); | ||
| 33 | use Data::Dumper; | ||
| 34 | use Module::Runtime qw(use_module); | ||
| 35 | use Log::Any qw($log); | ||
| 36 | use Date::Parse; | ||
| 37 | use DateTime; | ||
| 38 | use AsposeCellsCloud::Object::Color; | ||
| 39 | use AsposeCellsCloud::Object::GradientFill; | ||
| 40 | use AsposeCellsCloud::Object::Line; | ||
| 41 | use AsposeCellsCloud::Object::Link; | ||
| 42 | |||
| 43 | |||
| 44 | use base ("Class::Accessor", "Class::Data::Inheritable"); | ||
| 45 | |||
| 46 | |||
| 47 | |||
| 48 | __PACKAGE__->mk_classdata('attribute_map' => {}); | ||
| 49 | __PACKAGE__->mk_classdata('swagger_types' => {}); | ||
| 50 | __PACKAGE__->mk_classdata('method_documentation' => {}); | ||
| 51 | __PACKAGE__->mk_classdata('class_documentation' => {}); | ||
| 52 | |||
| 53 | # new object | ||
| 54 | sub new { | ||
| 55 | my ($class, %args) = @_; | ||
| 56 | |||
| 57 | my $self = bless {}, $class; | ||
| 58 | |||
| 59 | foreach my $attribute (keys %{$class->attribute_map}) { | ||
| 60 | my $args_key = $class->attribute_map->{$attribute}; | ||
| 61 | $self->$attribute( $args{ $args_key } ); | ||
| 62 | } | ||
| 63 | |||
| 64 | return $self; | ||
| 65 | } | ||
| 66 | |||
| 67 | # return perl hash | ||
| 68 | sub to_hash { | ||
| 69 | return decode_json(JSON->new->convert_blessed->encode( shift )); | ||
| 70 | } | ||
| 71 | |||
| 72 | # used by JSON for serialization | ||
| 73 | sub TO_JSON { | ||
| 74 | my $self = shift; | ||
| 75 | my $_data = {}; | ||
| 76 | foreach my $_key (keys %{$self->attribute_map}) { | ||
| 77 | if (defined $self->{$_key}) { | ||
| 78 | $_data->{$self->attribute_map->{$_key}} = $self->{$_key}; | ||
| 79 | } | ||
| 80 | } | ||
| 81 | return $_data; | ||
| 82 | } | ||
| 83 | |||
| 84 | # from Perl hashref | ||
| 85 | sub from_hash { | ||
| 86 | my ($self, $hash) = @_; | ||
| 87 | |||
| 88 | # loop through attributes and use swagger_types to deserialize the data | ||
| 89 | while ( my ($_key, $_type) = each %{$self->swagger_types} ) { | ||
| 90 | my $_json_attribute = $self->attribute_map->{$_key}; | ||
| 91 | if ($_type =~ /^array\[/i) { # array | ||
| 92 | my $_subclass = substr($_type, 6, -1); | ||
| 93 | my @_array = (); | ||
| 94 | foreach my $_element (@{$hash->{$_json_attribute}}) { | ||
| 95 | push @_array, $self->_deserialize($_subclass, $_element); | ||
| 96 | } | ||
| 97 | $self->{$_key} = \@_array; | ||
| 98 | } elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime | ||
| 99 | $self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute}); | ||
| 100 | } else { | ||
| 101 | $log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute); | ||
| 102 | } | ||
| 103 | } | ||
| 104 | |||
| 105 | return $self; | ||
| 106 | } | ||
| 107 | |||
| 108 | # deserialize non-array data | ||
| 109 | sub _deserialize { | ||
| 110 | my ($self, $type, $data) = @_; | ||
| 111 | $log->debugf("deserializing %s with %s",Dumper($data), $type); | ||
| 112 | |||
| 113 | if ($type eq 'DateTime') { | ||
| 114 | return DateTime->from_epoch(epoch => str2time($data)); | ||
| 115 | } elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) { | ||
| 116 | return $data; | ||
| 117 | } else { # hash(model) | ||
| 118 | my $_instance = eval "AsposeCellsCloud::Object::$type->new()"; | ||
| 119 | return $_instance->from_hash($data); | ||
| 120 | } | ||
| 121 | } | ||
| 122 | |||
| 123 | |||
| 124 | __PACKAGE__->class_documentation({description => 'Represents error bar of data series.', | ||
| 125 | class => 'ErrorBar', | ||
| 126 | required => [], # TODO | ||
| 127 | } ); | ||
| 128 | |||
| 129 | |||
| 130 | __PACKAGE__->method_documentation({ | ||
| 131 | 'link' => { | ||
| 132 | datatype => 'Link', | ||
| 133 | base_name => 'Link', | ||
| 134 | description => 'A property named "Link" of type "Link" that can be accessed and modified.', | ||
| 135 | format => '', | ||
| 136 | read_only => '', | ||
| 137 | }, | ||
| 138 | 'amount' => { | ||
| 139 | datatype => 'double', | ||
| 140 | base_name => 'Amount', | ||
| 141 | description => 'Represents amount of error bar. The amount must be greater than or equal to zero.', | ||
| 142 | format => '', | ||
| 143 | read_only => '', | ||
| 144 | }, | ||
| 145 | 'display_type' => { | ||
| 146 | datatype => 'string', | ||
| 147 | base_name => 'DisplayType', | ||
| 148 | description => 'Represents error bar display type.', | ||
| 149 | format => '', | ||
| 150 | read_only => '', | ||
| 151 | }, | ||
| 152 | 'minus_value' => { | ||
| 153 | datatype => 'string', | ||
| 154 | base_name => 'MinusValue', | ||
| 155 | description => 'Represents negative error amount when error bar type is Custom.', | ||
| 156 | format => '', | ||
| 157 | read_only => '', | ||
| 158 | }, | ||
| 159 | 'plus_value' => { | ||
| 160 | datatype => 'string', | ||
| 161 | base_name => 'PlusValue', | ||
| 162 | description => 'Represents positive error amount when error bar type is Custom.', | ||
| 163 | format => '', | ||
| 164 | read_only => '', | ||
| 165 | }, | ||
| 166 | 'show_marker_t_top' => { | ||
| 167 | datatype => 'boolean', | ||
| 168 | base_name => 'ShowMarkerTTop', | ||
| 169 | description => 'Indicates if formatting error bars with a T-top.', | ||
| 170 | format => '', | ||
| 171 | read_only => '', | ||
| 172 | }, | ||
| 173 | 'type' => { | ||
| 174 | datatype => 'string', | ||
| 175 | base_name => 'Type', | ||
| 176 | description => 'Represents error bar amount type.', | ||
| 177 | format => '', | ||
| 178 | read_only => '', | ||
| 179 | }, | ||
| 180 | 'begin_arrow_length' => { | ||
| 181 | datatype => 'string', | ||
| 182 | base_name => 'BeginArrowLength', | ||
| 183 | description => '', | ||
| 184 | format => '', | ||
| 185 | read_only => '', | ||
| 186 | }, | ||
| 187 | 'begin_arrow_width' => { | ||
| 188 | datatype => 'string', | ||
| 189 | base_name => 'BeginArrowWidth', | ||
| 190 | description => '', | ||
| 191 | format => '', | ||
| 192 | read_only => '', | ||
| 193 | }, | ||
| 194 | 'begin_type' => { | ||
| 195 | datatype => 'string', | ||
| 196 | base_name => 'BeginType', | ||
| 197 | description => '', | ||
| 198 | format => '', | ||
| 199 | read_only => '', | ||
| 200 | }, | ||
| 201 | 'cap_type' => { | ||
| 202 | datatype => 'string', | ||
| 203 | base_name => 'CapType', | ||
| 204 | description => '', | ||
| 205 | format => '', | ||
| 206 | read_only => '', | ||
| 207 | }, | ||
| 208 | 'color' => { | ||
| 209 | datatype => 'Color', | ||
| 210 | base_name => 'Color', | ||
| 211 | description => '', | ||
| 212 | format => '', | ||
| 213 | read_only => '', | ||
| 214 | }, | ||
| 215 | 'compound_type' => { | ||
| 216 | datatype => 'string', | ||
| 217 | base_name => 'CompoundType', | ||
| 218 | description => '', | ||
| 219 | format => '', | ||
| 220 | read_only => '', | ||
| 221 | }, | ||
| 222 | 'dash_type' => { | ||
| 223 | datatype => 'string', | ||
| 224 | base_name => 'DashType', | ||
| 225 | description => '', | ||
| 226 | format => '', | ||
| 227 | read_only => '', | ||
| 228 | }, | ||
| 229 | 'end_arrow_length' => { | ||
| 230 | datatype => 'string', | ||
| 231 | base_name => 'EndArrowLength', | ||
| 232 | description => '', | ||
| 233 | format => '', | ||
| 234 | read_only => '', | ||
| 235 | }, | ||
| 236 | 'end_arrow_width' => { | ||
| 237 | datatype => 'string', | ||
| 238 | base_name => 'EndArrowWidth', | ||
| 239 | description => '', | ||
| 240 | format => '', | ||
| 241 | read_only => '', | ||
| 242 | }, | ||
| 243 | 'end_type' => { | ||
| 244 | datatype => 'string', | ||
| 245 | base_name => 'EndType', | ||
| 246 | description => '', | ||
| 247 | format => '', | ||
| 248 | read_only => '', | ||
| 249 | }, | ||
| 250 | 'gradient_fill' => { | ||
| 251 | datatype => 'GradientFill', | ||
| 252 | base_name => 'GradientFill', | ||
| 253 | description => '', | ||
| 254 | format => '', | ||
| 255 | read_only => '', | ||
| 256 | }, | ||
| 257 | 'is_auto' => { | ||
| 258 | datatype => 'boolean', | ||
| 259 | base_name => 'IsAuto', | ||
| 260 | description => '', | ||
| 261 | format => '', | ||
| 262 | read_only => '', | ||
| 263 | }, | ||
| 264 | 'is_automatic_color' => { | ||
| 265 | datatype => 'boolean', | ||
| 266 | base_name => 'IsAutomaticColor', | ||
| 267 | description => '', | ||
| 268 | format => '', | ||
| 269 | read_only => '', | ||
| 270 | }, | ||
| 271 | 'is_visible' => { | ||
| 272 | datatype => 'boolean', | ||
| 273 | base_name => 'IsVisible', | ||
| 274 | description => '', | ||
| 275 | format => '', | ||
| 276 | read_only => '', | ||
| 277 | }, | ||
| 278 | 'join_type' => { | ||
| 279 | datatype => 'string', | ||
| 280 | base_name => 'JoinType', | ||
| 281 | description => '', | ||
| 282 | format => '', | ||
| 283 | read_only => '', | ||
| 284 | }, | ||
| 285 | 'style' => { | ||
| 286 | datatype => 'string', | ||
| 287 | base_name => 'Style', | ||
| 288 | description => '', | ||
| 289 | format => '', | ||
| 290 | read_only => '', | ||
| 291 | }, | ||
| 292 | 'transparency' => { | ||
| 293 | datatype => 'double', | ||
| 294 | base_name => 'Transparency', | ||
| 295 | description => '', | ||
| 296 | format => '', | ||
| 297 | read_only => '', | ||
| 298 | }, | ||
| 299 | 'weight' => { | ||
| 300 | datatype => 'string', | ||
| 301 | base_name => 'Weight', | ||
| 302 | description => '', | ||
| 303 | format => '', | ||
| 304 | read_only => '', | ||
| 305 | }, | ||
| 306 | 'weight_pt' => { | ||
| 307 | datatype => 'double', | ||
| 308 | base_name => 'WeightPt', | ||
| 309 | description => '', | ||
| 310 | format => '', | ||
| 311 | read_only => '', | ||
| 312 | }, | ||
| 313 | }); | ||
| 314 | |||
| 315 | __PACKAGE__->swagger_types( { | ||
| 316 | 'link' => 'Link', | ||
| 317 | 'amount' => 'double', | ||
| 318 | 'display_type' => 'string', | ||
| 319 | 'minus_value' => 'string', | ||
| 320 | 'plus_value' => 'string', | ||
| 321 | 'show_marker_t_top' => 'boolean', | ||
| 322 | 'type' => 'string', | ||
| 323 | 'begin_arrow_length' => 'string', | ||
| 324 | 'begin_arrow_width' => 'string', | ||
| 325 | 'begin_type' => 'string', | ||
| 326 | 'cap_type' => 'string', | ||
| 327 | 'color' => 'Color', | ||
| 328 | 'compound_type' => 'string', | ||
| 329 | 'dash_type' => 'string', | ||
| 330 | 'end_arrow_length' => 'string', | ||
| 331 | 'end_arrow_width' => 'string', | ||
| 332 | 'end_type' => 'string', | ||
| 333 | 'gradient_fill' => 'GradientFill', | ||
| 334 | 'is_auto' => 'boolean', | ||
| 335 | 'is_automatic_color' => 'boolean', | ||
| 336 | 'is_visible' => 'boolean', | ||
| 337 | 'join_type' => 'string', | ||
| 338 | 'style' => 'string', | ||
| 339 | 'transparency' => 'double', | ||
| 340 | 'weight' => 'string', | ||
| 341 | 'weight_pt' => 'double' | ||
| 342 | } ); | ||
| 343 | |||
| 344 | __PACKAGE__->attribute_map( { | ||
| 345 | 'link' => 'Link', | ||
| 346 | 'amount' => 'Amount', | ||
| 347 | 'display_type' => 'DisplayType', | ||
| 348 | 'minus_value' => 'MinusValue', | ||
| 349 | 'plus_value' => 'PlusValue', | ||
| 350 | 'show_marker_t_top' => 'ShowMarkerTTop', | ||
| 351 | 'type' => 'Type', | ||
| 352 | 'begin_arrow_length' => 'BeginArrowLength', | ||
| 353 | 'begin_arrow_width' => 'BeginArrowWidth', | ||
| 354 | 'begin_type' => 'BeginType', | ||
| 355 | 'cap_type' => 'CapType', | ||
| 356 | 'color' => 'Color', | ||
| 357 | 'compound_type' => 'CompoundType', | ||
| 358 | 'dash_type' => 'DashType', | ||
| 359 | 'end_arrow_length' => 'EndArrowLength', | ||
| 360 | 'end_arrow_width' => 'EndArrowWidth', | ||
| 361 | 'end_type' => 'EndType', | ||
| 362 | 'gradient_fill' => 'GradientFill', | ||
| 363 | 'is_auto' => 'IsAuto', | ||
| 364 | 'is_automatic_color' => 'IsAutomaticColor', | ||
| 365 | 'is_visible' => 'IsVisible', | ||
| 366 | 'join_type' => 'JoinType', | ||
| 367 | 'style' => 'Style', | ||
| 368 | 'transparency' => 'Transparency', | ||
| 369 | 'weight' => 'Weight', | ||
| 370 | 'weight_pt' => 'WeightPt' | ||
| 371 | } ); | ||
| 372 | |||
| 373 | __PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map}); | ||
| 374 | |||
| 375 | |||
| 376 | 1; |