Skip to content

Commit

Permalink
Merge pull request OpenFlutter#23 from karanchuri/feat/customize-k-ch…
Browse files Browse the repository at this point in the history
…art-widget

Customize K Chart UI
  • Loading branch information
mafanwei authored May 14, 2021
2 parents 75e2617 + e752900 commit d0faaac
Show file tree
Hide file tree
Showing 12 changed files with 287 additions and 304 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Container(
height: 450,
width: double.infinity,
child: KChartWidget(
chartStyle, // Required for styling purposes
chartColors,// Required for styling purposes
datas,// Required,Data must be an ordered list,(history=>now)
isLine: isLine,// Decide whether it is k-line or time-sharing
mainState: _mainState,// Decide what the main view shows
Expand Down Expand Up @@ -59,7 +61,7 @@ if you want change DepthChart color, you can use just like this:
height: 230,
width: double.infinity,
color: Colors.grey, //background color
child: DepthChart(_bids, _asks,buyPathColor: Colors.blue, sellPathColor: Colors.green),
child: DepthChart(_bids, _asks, chartColors, buyPathColor: Colors.blue, sellPathColor: Colors.green),
)
```

Expand Down
16 changes: 15 additions & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:k_chart/chart_style.dart';
import 'package:k_chart/flutter_k_chart.dart';
import 'package:k_chart/k_chart_widget.dart';
import 'package:http/http.dart' as http;
Expand Down Expand Up @@ -40,6 +41,9 @@ class _MyHomePageState extends State<MyHomePage> {
bool isChinese = true;
List<DepthEntity> _bids, _asks;

ChartStyle chartStyle = new ChartStyle();
ChartColors chartColors = new ChartColors();

@override
void initState() {
super.initState();
Expand Down Expand Up @@ -96,6 +100,8 @@ class _MyHomePageState extends State<MyHomePage> {
width: double.infinity,
child: KChartWidget(
datas,
chartStyle,
chartColors,
isLine: isLine,
mainState: _mainState,
volHidden: _volHidden,
Expand All @@ -116,7 +122,7 @@ class _MyHomePageState extends State<MyHomePage> {
Container(
height: 230,
width: double.infinity,
child: DepthChart(_bids, _asks),
child: DepthChart(_bids, _asks, this.chartColors),
)
],
),
Expand All @@ -140,6 +146,14 @@ class _MyHomePageState extends State<MyHomePage> {
button("隐藏副视图", onPressed: () => _secondaryState = SecondaryState.NONE),
button(_volHidden ? "显示成交量" : "隐藏成交量", onPressed: () => _volHidden = !_volHidden),
button("切换中英文", onPressed: () => isChinese = !isChinese),
button("Customize UI", onPressed: () {
setState(() {
chartColors.selectBorderColor = Colors.red;
chartColors.selectFillColor = Colors.red;
chartColors.lineFillColor = Colors.red;
chartColors.kLineColor = Colors.yellow;
});
}),
],
);
}
Expand Down
147 changes: 56 additions & 91 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
@@ -1,69 +1,62 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
archive:
dependency: transitive
description:
name: archive
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.13"
args:
dependency: transitive
description:
name: args
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.6.0"
async:
dependency: transitive
description:
name: async
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.1"
version: "2.5.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
charcode:
version: "2.1.0"
characters:
dependency: transitive
description:
name: charcode
url: "https://pub.flutter-io.cn"
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.3"
collection:
version: "1.1.0"
charcode:
dependency: transitive
description:
name: collection
url: "https://pub.flutter-io.cn"
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.12"
convert:
version: "1.2.0"
clock:
dependency: transitive
description:
name: convert
url: "https://pub.flutter-io.cn"
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
crypto:
version: "1.1.0"
collection:
dependency: transitive
description:
name: crypto
url: "https://pub.flutter-io.cn"
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.4"
version: "1.15.0"
cupertino_icons:
dependency: "direct main"
description:
name: cupertino_icons
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -78,72 +71,51 @@ packages:
dependency: "direct main"
description:
name: http
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.2"
http_parser:
dependency: transitive
description:
name: http_parser
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.4"
image:
dependency: transitive
description:
name: image
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.12"
k_chart:
dependency: "direct main"
description:
path: ".."
relative: true
source: path
version: "0.1.1"
version: "0.1.4"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.6"
version: "0.12.10"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.8"
version: "1.3.0"
path:
dependency: transitive
description:
name: path
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.4"
version: "1.8.0"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.9.0"
petitparser:
dependency: transitive
description:
name: petitparser
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.0"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.3"
version: "1.11.0"
sky_engine:
dependency: transitive
description: flutter
Expand All @@ -153,64 +125,57 @@ packages:
dependency: transitive
description:
name: source_span
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.0"
version: "1.8.0"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.9.3"
version: "1.10.0"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.1.0"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.5"
version: "1.1.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.2.0"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.15"
version: "0.2.19"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.6"
version: "1.3.0"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.8"
xml:
dependency: transitive
description:
name: xml
url: "https://pub.flutter-io.cn"
url: "https://pub.dartlang.org"
source: hosted
version: "3.6.1"
version: "2.1.0"
sdks:
dart: ">=2.6.0 <3.0.0"
dart: ">=2.12.0-0.0 <3.0.0"
Loading

0 comments on commit d0faaac

Please sign in to comment.