New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chart disappears when data are updated #29
Comments
It should. |
return Observer(builder: (_) {
if (context.watch<ResultatsStore>().answersChart.isEmpty) {
return Center(
child: Text(
'Aucune donnée disponible',
style: Theme.of(context).textTheme.headline6,
),
);
}
return Chart(
data: context.watch<ResultatsStore>().answersChart,
variables: {
'Note': Variable(
accessor: (Map map) => map['Note'] as String,
),
'Réponses': Variable(
accessor: (Map map) => map['Réponses'] as num,
),
'index': Variable(
accessor: (Map map) => map['index'] as num,
),
},
elements: [
IntervalElement(
color: ColorAttr(
variable: 'index',
values: [
Palette.rose,
Palette.green,
Palette.grey,
],
),
size: SizeAttr(
value: (mediaQuery.width /
context.watch<ResultatsStore>().answersChart.length) *
0.5,
),
),
],
axes: [
Defaults.horizontalAxis,
Defaults.verticalAxis,
],
selections: {
'tap': PointSelection(
on: {
GestureType.hover,
GestureType.tap,
},
dim: 1,
)
},
tooltip: TooltipGuide(
backgroundColor: Palette.black,
elevation: 5,
textStyle: TextStyles.caption.copyWith(color: Palette.white),
variables: ['Note', 'Réponses'],
),
crosshair: CrosshairGuide(),
);
}); Note here that @action
void calculateAnswersChart() {
answersChart.clear();
log.fine('calculateAnswersChart | rs.copyMap: ${copyMap.length}');
for (final entry in copyMap.entries) {
final copy = entry.value;
final notes = copy.notes[critere?.idDef];
final notesStr = (critere as Question)
.propositions
.map((e) => String.fromCharCode(96 + e.numero).toUpperCase())
.toSet()
.toList();
String note = '';
// fill with all default notes
for (final noteStr in notesStr) {
answersChart.add(ObservableMap<String, dynamic>.of(<String, dynamic>{
'index': 0,
'Note': noteStr,
'Réponses': 0,
}));
}
etc... PS: somehow I can't click on the graph bars |
Also, even if I remove the The only way to have the updated chart is to switch to a different view and then come back to the chart. |
The data updating problem is caused by a bug in the _ChartLayoutDelegate. The click problem dosen't show in my test, I copied your selections and tooltip setting. |
Oh one last problem, seems like in a bar chart, say there are 2 labels and each one have a value of 1, no bar is displayed Example, if this is my data: |
If the label position is right, the problem may caused by color or size attribute. |
I'll take a look, thanks. I close the issue since the original one is patched (works like a charm). |
When I update the data used by the chart (I use mobx to update the data), it just disappears. Shouldn't the data be updatable in real-time?
The text was updated successfully, but these errors were encountered: