base_dimension.dart 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import '../k_chart_widget.dart';
  2. /// Base Dimension
  3. class BaseDimension {
  4. // the height of base chart
  5. double _mBaseHeight = 380;
  6. // default: 0
  7. // the height of volume chart
  8. double _mVolumeHeight = 0;
  9. // default: 0
  10. // the height of a secondary chart
  11. double _mSecondaryHeight = 0;
  12. double _totalSecondaryHeight = 0;
  13. double _mLabelHeight = 12;
  14. double _totalLabelHeight = 12;
  15. // total height of chart: _mBaseHeight + _mVolumeHeight + (_mSecondaryHeight * n)
  16. // n : number of secondary charts
  17. //
  18. double _mDisplayHeight = 0;
  19. // getter the vol height
  20. double get mVolumeHeight => _mVolumeHeight;
  21. // getter the secondary height
  22. double get mSecondaryHeight => _mSecondaryHeight;
  23. double get totalSecondaryHeight => _totalSecondaryHeight;
  24. double get mLabelHeight => _mLabelHeight;
  25. double get totalLabelHeight => _totalLabelHeight;
  26. // getter the total height
  27. double get mDisplayHeight => _mDisplayHeight;
  28. /// constructor
  29. ///
  30. /// BaseDimension
  31. /// set _mBaseHeight
  32. /// compute value of _mVolumeHeight, _mSecondaryHeight, _mDisplayHeight
  33. BaseDimension({
  34. required double mBaseHeight,
  35. required bool volHidden,
  36. required Set<SecondaryState> secondaryStateLi,
  37. required Set<MainState> mainStateLi,
  38. }) {
  39. _mBaseHeight = mBaseHeight;
  40. _mVolumeHeight = volHidden != true ? _mBaseHeight * 0.2 : 0;
  41. _mSecondaryHeight = _mBaseHeight * 0.2;
  42. _totalSecondaryHeight = _mSecondaryHeight * secondaryStateLi.length;
  43. _totalLabelHeight = _mLabelHeight * mainStateLi.length;
  44. _mDisplayHeight = _mBaseHeight +
  45. _mVolumeHeight +
  46. _totalSecondaryHeight +
  47. _totalLabelHeight;
  48. }
  49. }