chart_style.dart 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. import 'package:flutter/material.dart' show Color;
  2. /// ChartColors
  3. ///
  4. /// Note:
  5. /// If you need to apply multi theme, you need to change at least the colors related to the text, border and background color
  6. /// Ex:
  7. /// Background: bgColor, selectFillColor
  8. /// Border
  9. /// Text
  10. ///
  11. class ChartColors {
  12. /// the background color of base chart
  13. Color bgColor;
  14. Color kLineColor;
  15. ///
  16. Color lineFillColor;
  17. ///
  18. Color lineFillInsideColor;
  19. /// color: ma5, ma10, ma30, up, down, vol, macd, diff, dea, k, d, j, rsi
  20. Color ma5Color;
  21. Color ma10Color;
  22. Color ma30Color;
  23. Color upColor;
  24. Color dnColor;
  25. Color volColor;
  26. Color macdColor;
  27. Color difColor;
  28. Color deaColor;
  29. Color kColor;
  30. Color dColor;
  31. Color jColor;
  32. Color rsiColor;
  33. Color sarColor;
  34. Color avgColor;
  35. /// default text color: apply for text at grid
  36. Color defaultTextColor;
  37. /// color of the current price
  38. Color nowPriceUpColor;
  39. Color nowPriceDnColor;
  40. Color nowPriceTextColor;
  41. /// trend color
  42. Color trendLineColor;
  43. /// depth color
  44. Color depthBuyColor; //upColor
  45. Color depthBuyPathColor;
  46. Color depthSellColor; //dnColor
  47. Color depthSellPathColor;
  48. ///value border color after selection
  49. Color selectBorderColor;
  50. ///background color when value selected
  51. Color selectFillColor;
  52. ///color of grid
  53. Color gridColor;
  54. ///color of annotation content
  55. Color infoWindowNormalColor;
  56. Color infoWindowTitleColor;
  57. Color infoWindowUpColor;
  58. Color infoWindowDnColor;
  59. /// color of the horizontal cross line
  60. Color hCrossColor;
  61. /// color of the vertical cross line
  62. Color vCrossColor;
  63. /// text color
  64. Color crossTextColor;
  65. ///The color of the maximum and minimum values in the current display
  66. Color maxColor;
  67. Color minColor;
  68. /// get MA color via index
  69. Color getMAColor(int index) {
  70. switch (index % 3) {
  71. case 1:
  72. return ma10Color;
  73. case 2:
  74. return ma30Color;
  75. default:
  76. return ma5Color;
  77. }
  78. }
  79. /// constructor chart color
  80. ChartColors({
  81. this.bgColor = const Color(0xffffffff),
  82. this.kLineColor = const Color(0xff4C86CD),
  83. ///
  84. this.lineFillColor = const Color(0x554C86CD),
  85. ///
  86. this.lineFillInsideColor = const Color(0x00000000),
  87. ///
  88. this.ma5Color = const Color(0xffE5B767),
  89. this.ma10Color = const Color(0xff1FD1AC),
  90. this.ma30Color = const Color(0xffB48CE3),
  91. this.upColor = const Color(0xFF14AD8F),
  92. this.dnColor = const Color(0xFFD5405D),
  93. this.volColor = const Color(0xff2f8fd5),
  94. this.macdColor = const Color(0xff2f8fd5),
  95. this.difColor = const Color(0xffE5B767),
  96. this.deaColor = const Color(0xff1FD1AC),
  97. this.kColor = const Color(0xffE5B767),
  98. this.dColor = const Color(0xff1FD1AC),
  99. this.jColor = const Color(0xffB48CE3),
  100. this.rsiColor = const Color(0xffE5B767),
  101. this.defaultTextColor = const Color(0xFF909196),
  102. this.nowPriceUpColor = const Color(0xFF14AD8F),
  103. this.nowPriceDnColor = const Color(0xFFD5405D),
  104. this.nowPriceTextColor = const Color(0xffffffff),
  105. this.sarColor = const Color(0xffE5B767),
  106. this.avgColor = const Color(0xff82878e),
  107. /// trend color
  108. this.trendLineColor = const Color(0xFFF89215),
  109. ///depth color
  110. this.depthBuyColor = const Color(0xFF14AD8F),
  111. this.depthBuyPathColor = const Color(0x3314AD8F),
  112. this.depthSellColor = const Color(0xFFD5405D),
  113. this.depthSellPathColor = const Color(0x33D5405D),
  114. ///value border color after selection
  115. this.selectBorderColor = const Color(0xFF222223),
  116. ///background color when value selected
  117. this.selectFillColor = const Color(0xffffffff),
  118. ///color of grid
  119. this.gridColor = const Color(0xFFD1D3DB),
  120. ///color of annotation content
  121. this.infoWindowNormalColor = const Color(0xFF222223),
  122. this.infoWindowTitleColor = const Color(0xFF4D4D4E), //0xFF707070
  123. this.infoWindowUpColor = const Color(0xFF14AD8F),
  124. this.infoWindowDnColor = const Color(0xFFD5405D),
  125. this.hCrossColor = const Color(0xFF222223),
  126. this.vCrossColor = const Color(0x28424652),
  127. this.crossTextColor = const Color(0xFF222223),
  128. ///The color of the maximum and minimum values in the current display
  129. this.maxColor = const Color(0xFF222223),
  130. this.minColor = const Color(0xFF222223),
  131. });
  132. }
  133. class ChartStyle {
  134. double topPadding = 20.0;
  135. double bottomPadding = 20.0;
  136. double childPadding = 12.0;
  137. ///point-to-point distance
  138. double pointWidth = 11.0;
  139. ///candle width
  140. double candleWidth = 8.5;
  141. double candleLineWidth = 1.0;
  142. ///vol column width
  143. double volWidth = 8.5;
  144. ///macd column width
  145. double macdWidth = 1.2;
  146. ///vertical-horizontal cross line width
  147. double vCrossWidth = 8.5;
  148. double hCrossWidth = 0.5;
  149. ///(line length - space line - thickness) of the current price
  150. double nowPriceLineLength = 4.5;
  151. double nowPriceLineSpan = 3.5;
  152. double nowPriceLineWidth = 1;
  153. int gridRows = 4;
  154. int gridColumns = 4;
  155. ///customize the time below
  156. List<String>? dateTimeFormat;
  157. }