SunPointed / MPFlutterChart

MPAndroidChart Flutter version
Apache License 2.0
305 stars 166 forks source link

How to highlight multiple values ? #142

Open Arnooow opened 4 years ago

Arnooow commented 4 years ago

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

ekuleshov commented 3 years ago

It is supposed to be like

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

But I couldn't get that to work

greensopinion commented 3 years ago

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.

sky1095 commented 2 years ago

@Arnooow have you find any solution to this?

sky1095 commented 2 years ago

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