google / charts

https://pub.dev/packages/charts_flutter
Apache License 2.0
2.81k stars 1.2k forks source link

Showing legends and values on particular point - Stacked area chart #770

Open elmar001 opened 2 years ago

elmar001 commented 2 years ago

How to show legends of stacked area chart? Is it possible? And also is there a way to show values when user clicks on specific part of stacked area chart.

elmar001 commented 2 years ago

Ok, I found the way for legends: behaviors: [ new charts.SeriesLegend( // Positions for "start" and "end" will be left and right respectively // for widgets with a build context that has directionality ltr. // For rtl, "start" and "end" will be right and left respectively. // Since this example has directionality of ltr, the legend is // positioned on the right side of the chart. position: charts.BehaviorPosition.end, // For a legend that is positioned on the left or right of the chart, // setting the justification for [endDrawArea] is aligned to the // bottom of the chart draw area. outsideJustification: charts.OutsideJustification.endDrawArea, // By default, if the position of the chart is on the left or right of // the chart, [horizontalFirst] is set to false. This means that the // legend entries will grow as new rows first instead of a new column. horizontalFirst: false, // By setting this value to 2, the legend entries will grow up to two // rows before adding a new column. desiredMaxRows: 2, // This defines the padding around each legend entry. cellPadding: new EdgeInsets.only(right: 4.0, bottom: 4.0), // Render the legend entry text with custom styles. entryTextStyle: charts.TextStyleSpec( color: charts.Color(r: 127, g: 63, b: 191), fontFamily: 'Georgia', fontSize: 11), ) ],