-
Notifications
You must be signed in to change notification settings - Fork 775
Closed
Description
Hi!, I am developing an app in which I want to show a line graph. In this graph I want to show in which room an individual has been in at any given moment. To do this we have a list called roomList with the following structure:
class RoomData {
String room;
DateTime timestamp;
int CodHabitacionSensor;
RoomData(this.room, this.timestamp, this.CodHabitacionSensor);
}
As shown this list contains three variables, room is a string that for example is bathroom whose CodHabitacionSensor corresponds to 3, what I have achieved so far is to show the graph with the integers, however I am not able to put on the Y axis the string bathroom, and I can only represent the integer CodHabitacionSensor . Next I show you the implemented code
child: SfCartesianChart(
plotAreaBorderWidth: 0,
primaryXAxis: DateTimeAxis(
dateFormat: DateFormat('HH:mm d/M/y'),
majorGridLines: const MajorGridLines(width: 0)),
primaryYAxis: NumericAxis(
axisLine: const AxisLine(width: 0),
labelFormat: '{value} ',
majorTickLines: const MajorTickLines(size: 0)),
series: _getRoomLineSeries(),
trackballBehavior: _trackballBehavior,
),
List<LineSeries<RoomData, DateTime>> _getRoomLineSeries() {
return <LineSeries<RoomData, DateTime>>[
LineSeries<RoomData, DateTime>(
animationDuration: 2500,
dataSource: roomList!,
xValueMapper: (RoomData sales, _) => sales.timestamp,
yValueMapper: (RoomData sales, _) => sales.CodHabitacionSensor,
width: 2,
markerSettings: const MarkerSettings(isVisible: true)),
];
}
Metadata
Metadata
Assignees
Labels
No labels