Skip to content

Commit

Permalink
Update demo Add lineFillInsideColor
Browse files Browse the repository at this point in the history
  • Loading branch information
mafanwei committed Apr 14, 2022
1 parent 0e2eee0 commit 7c50675
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
15 changes: 13 additions & 2 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class _MyHomePageState extends State<MyHomePage> {
List<DepthEntity>? _bids, _asks;
bool isChangeUI = false;
bool _isTrendLine = false;
bool _priceLeft = true;
VerticalTextAlignment _verticalTextAlignment = VerticalTextAlignment.left;

ChartStyle chartStyle = ChartStyle();
ChartColors chartColors = ChartColors();
Expand Down Expand Up @@ -121,6 +123,7 @@ class _MyHomePageState extends State<MyHomePage> {
isChinese: isChinese,
hideGrid: _hideGrid,
isTapShowInfoDialog: false,
verticalTextAlignment: _verticalTextAlignment,
maDayList: [1, 100, 1000],
),
),
Expand Down Expand Up @@ -187,6 +190,14 @@ class _MyHomePageState extends State<MyHomePage> {
}
});
}),
button("Change PriceTextPaint", onPressed: () => setState(() {
_priceLeft = !_priceLeft;
if(_priceLeft) {
_verticalTextAlignment = VerticalTextAlignment.left;
} else {
_verticalTextAlignment = VerticalTextAlignment.right;
}
}) ),
],
);
}
Expand Down Expand Up @@ -216,8 +227,8 @@ class _MyHomePageState extends State<MyHomePage> {
/*
* 可以翻墙使用方法1加载数据,不可以翻墙使用方法2加载数据,默认使用方法1加载最新数据
*/
final Future<String> future = getChatDataFromInternet(period);
// final Future<String> future = getChatDataFromJson();
//final Future<String> future = getChatDataFromInternet(period);
final Future<String> future = getChatDataFromJson();
future.then((String result) {
solveChatData(result);
}).catchError((_) {
Expand Down
1 change: 1 addition & 0 deletions lib/chart_style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class ChartColors {

Color kLineColor = Color(0xff4C86CD);
Color lineFillColor = Color(0x554C86CD);
Color lineFillInsideColor = Color(0x00000000);
Color ma5Color = Color(0xffC9B885);
Color ma10Color = Color(0xff6CB0A6);
Color ma30Color = Color(0xff9979C6);
Expand Down
18 changes: 9 additions & 9 deletions lib/renderer/main_renderer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ class MainRenderer extends BaseChartRenderer<CandleEntity> {
@override
void drawChart(CandleEntity lastPoint, CandleEntity curPoint, double lastX,
double curX, Size size, Canvas canvas) {
if (isLine != true) {
drawCandle(curPoint, canvas, curX);
}
if (isLine == true) {
if (isLine) {
drawPolyline(lastPoint.close, curPoint.close, canvas, lastX, curX);
} else if (state == MainState.MA) {
drawMaLine(lastPoint, curPoint, canvas, lastX, curX);
} else if (state == MainState.BOLL) {
drawBollLine(lastPoint, curPoint, canvas, lastX, curX);
} else {
drawCandle(curPoint, canvas, curX);
if (state == MainState.MA) {
drawMaLine(lastPoint, curPoint, canvas, lastX, curX);
} else if (state == MainState.BOLL) {
drawBollLine(lastPoint, curPoint, canvas, lastX, curX);
}
}
}

Expand Down Expand Up @@ -155,7 +155,7 @@ class MainRenderer extends BaseChartRenderer<CandleEntity> {
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
tileMode: TileMode.clamp,
colors: [this.chartColors.lineFillColor, Colors.transparent],
colors: [this.chartColors.lineFillColor, this.chartColors.lineFillInsideColor],
).createShader(Rect.fromLTRB(
chartRect.left, chartRect.top, chartRect.right, chartRect.bottom));
mLineFillPaint..shader = mLineFillShader;
Expand Down

0 comments on commit 7c50675

Please sign in to comment.