Created
July 1, 2022 13:17
-
-
Save sakinaboriwala/a68b9c3b9ea141c6a5f4c1a1548bb431 to your computer and use it in GitHub Desktop.
LineChart Sample for HIghCharts Demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:high_chart/high_chart.dart'; | |
class LineChart extends StatelessWidget { | |
const LineChart({Key? key}) : super(key: key); | |
final String _chartData = '''{ | |
accessibility: { | |
enabled: false | |
}, | |
title: { | |
text: 'Solar Employment Growth by Sector, 2010-2016' | |
}, | |
subtitle: { | |
text: 'Source: thesolarfoundation.com' | |
}, | |
yAxis: { | |
title: { | |
text: 'Number of Employees' | |
} | |
}, | |
xAxis: { | |
}, | |
legend: { | |
layout: 'vertical', | |
align: 'right', | |
verticalAlign: 'middle' | |
}, | |
plotOptions: { | |
series: { | |
label: { | |
connectorAllowed: false | |
}, | |
pointStart: 2010 | |
} | |
}, | |
series: [{ | |
name: 'Installation', | |
data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175] | |
} | |
], | |
responsive: { | |
rules: [{ | |
condition: { | |
maxWidth: 500 | |
}, | |
chartOptions: { | |
legend: { | |
layout: 'horizontal', | |
align: 'center', | |
verticalAlign: 'bottom' | |
} | |
} | |
}] | |
} | |
}'''; | |
@override | |
Widget build(BuildContext context) { | |
return Padding( | |
padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 2), | |
child: HighCharts( | |
loader: const SizedBox( | |
child: LinearProgressIndicator(), | |
width: 200, | |
), | |
size: const Size(400, 400), | |
data: _chartData, | |
scripts: const [ | |
"https://code.highcharts.com/highcharts.js", | |
], | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment