MPFlutterChart icon indicating copy to clipboard operation
MPFlutterChart copied to clipboard

How to highlight multiple values ?

Open Arnooow opened this issue 3 years ago • 4 comments

Hi everyone,

First thanks for this incredible work to import MPandroidChart in flutter !

Is it possible to highlight several values ? Like we can do in MPAndroidChart with chart.highlightValues(new Highlight[] {h1, h2});

Arno

Arnooow avatar Oct 20 '20 16:10 Arnooow

It is supposed to be like

LineChartController.painter.highlightValues([ h1, h2 ]);

But I couldn't get that to work

ekuleshov avatar Feb 14 '21 05:02 ekuleshov

It is supposed to be like

LineChartController.painter.highlightValues([ h1, h2 ]);

But I couldn't get that to work

For a single value I found the following was also necessary:

controller.state?.lastHighlighted =
            highlights.length == 0 ? null : highlights[0];

The state must be updated because the painter is recreated every time build is called on the chart.

greensopinion avatar Apr 27 '21 14:04 greensopinion

@Arnooow have you find any solution to this?

sky1095 avatar Mar 09 '22 08:03 sky1095

It is supposed to be like

LineChartController.painter.highlightValues([ h1, h2 ]);

But I couldn't get that to work

I did add this to the line_chart_controller.dart,

void highlight(List<Highlight> highlights) {
    painter?.highlightValues(highlights);
    state?.lastHighlighted = highlights.length == 0 ? null : highlights[0];
    state?.setStateIfNotDispose();
  }

yet it didn't seem to work

sky1095 avatar Mar 09 '22 08:03 sky1095