ModelGraphAxisSpec class

Describes metadata for a simple 2D chart axis.

Holds a human-readable title and an inclusive numeric range defined by min and max. The model is immutable and supports JSON (de)serialization and value-based equality.

Contracts

  • fromJson is lenient and never throws:
    • title is stringified via Utils.getStringFromDynamic.
    • min and max are parsed via Utils.getDouble, which may return double.nan for invalid inputs.
  • No invariant checks are enforced here:
    • min may be greater than max.
    • Non-finite values (NaN, ±Infinity) may be accepted. Validate these in higher layers if required.

Example

void main() {
  // Construction
  const GraphAxisSpec x = GraphAxisSpec(title: 'Month', min: 1.0, max: 12.0);
  const GraphAxisSpec y = GraphAxisSpec(title: 'Price', min: 55000.0, max: 65000.0);
  print(x.toJson()); // { "title": "Month", "min": 1.0, "max": 12.0 }

  // JSON round-trip
  final Map<String, dynamic> j = <String, dynamic>{
    'title': 'Units',
    'min': 0,
    'max': 100,
  };
  final GraphAxisSpec a = GraphAxisSpec.fromJson(j);
  print('${a.title} [${a.min}, ${a.max}]'); // Units [0.0, 100.0]
}
Inheritance

Constructors

ModelGraphAxisSpec({required String title, required double min, required double max})
const
ModelGraphAxisSpec.fromJson(Map<String, dynamic> json)
Builds a ModelGraphAxisSpec from a JSON map.
factory

Properties

hashCode int
Gets the hash code for this entity model.
no setteroverride
max double
Inclusive maximum bound.
final
min double
Inclusive minimum bound.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
title String
Axis title (human-readable).
final

Methods

copyWith({String? title, double? min, double? max}) ModelGraphAxisSpec
Returns a copy with optional overrides.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
Serializes this model to JSON
override
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
Value-based equality on title, min, and max.
override