We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi ,
I want to map gradient in the Spline Area Chart. The colors received from the server depending on the y value. Please suggest how to achieve this.
SfCartesianChart( primaryXAxis: const CategoryAxis( initialZoomFactor: 0.1, initialZoomPosition: 1.0, interval: 1, // maximum: 10, title: AxisTitle(text: 'Time', textStyle: TextStyle(color: lightTextColor)), isVisible: true, majorGridLines: MajorGridLines(width: 0), majorTickLines: MajorTickLines(width: 0), axisLine: AxisLine(color: Colors.transparent), ), primaryYAxis: const NumericAxis( minimum: 0, maximum: 25, interval: 5, isVisible: true, majorGridLines: MajorGridLines(width: 0), majorTickLines: MajorTickLines(width: 0), axisLine: AxisLine(color: Colors.transparent), ), zoomPanBehavior: ZoomPanBehavior( enablePanning: true, enablePinching: false, zoomMode: ZoomMode.x, enableDoubleTapZooming: true, ), plotAreaBorderWidth: 0, legend: const Legend(isVisible: false), tooltipBehavior: TooltipBehavior(enable: false), series: _series(), onZoomEnd: (ZoomPanArgs args) { // print(args.axis!.visibleLabels[0].text); if (args.axis!.name == 'primaryXAxis' && args.axis!.visibleLabels[0].text == somData[0].minute) { print('solution found'); onScrollToStart(somData[0].minute ?? ""); } }, ),
_series() { int? lastValidYValue; List<CartesianSeries<dynamic, dynamic>> series = []; series.add(SplineSeries<SomOverview, String>( color: Colors.black, width: 1.0, dataSource: somData, animationDuration: 0, pointColorMapper: (SomOverview model, _) => hexToColor(model.somColor!), xValueMapper: (SomOverview model, _) => model.minute, yValueMapper: (SomOverview model, int idx) { int bpm = double.parse(model.bpmAvg ?? "0.0").toInt(); if(bpm == 0) { return lastValidYValue ?? 0; } else { lastValidYValue = bpm; return bpm; } }, )); int? lastVal; for (int index = 0;index<(somData.length-1);index++) { series.add(SplineAreaSeries<SomOverview, String>( color: Colors.black, animationDuration: 0, gradient: LinearGradient(colors: [hexToColor(somData[index].somColor ?? "#ffffff").withOpacity(0.8), hexToColor(somData[index].somColor ?? "#ffffff").withOpacity(0.0)], begin: Alignment.topCenter, end: Alignment.bottomCenter), dataSource: [somData[index],somData[index+1]], xValueMapper: (SomOverview model, _) => model.minute, yValueMapper: (SomOverview model, _) { int bpm = double.parse(model.bpmAvg ?? "0.0").toInt(); if(bpm == 0) { return lastVal; } else { lastVal = bpm; return bpm; } }, )); } return series; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Use case
Hi ,
I want to map gradient in the Spline Area Chart. The colors received from the server depending on the y value.
Please suggest how to achieve this.
Proposal
SfCartesianChart(
primaryXAxis: const CategoryAxis(
initialZoomFactor: 0.1,
initialZoomPosition: 1.0,
interval: 1,
// maximum: 10,
title: AxisTitle(text: 'Time', textStyle: TextStyle(color: lightTextColor)),
isVisible: true,
majorGridLines: MajorGridLines(width: 0),
majorTickLines: MajorTickLines(width: 0),
axisLine: AxisLine(color: Colors.transparent),
),
primaryYAxis: const NumericAxis(
minimum: 0,
maximum: 25,
interval: 5,
isVisible: true,
majorGridLines: MajorGridLines(width: 0),
majorTickLines: MajorTickLines(width: 0),
axisLine: AxisLine(color: Colors.transparent),
),
zoomPanBehavior: ZoomPanBehavior(
enablePanning: true,
enablePinching: false,
zoomMode: ZoomMode.x,
enableDoubleTapZooming: true,
),
plotAreaBorderWidth: 0,
legend: const Legend(isVisible: false),
tooltipBehavior: TooltipBehavior(enable: false),
series: _series(),
onZoomEnd: (ZoomPanArgs args) {
// print(args.axis!.visibleLabels[0].text);
if (args.axis!.name == 'primaryXAxis' && args.axis!.visibleLabels[0].text == somData[0].minute) {
print('solution found');
onScrollToStart(somData[0].minute ?? "");
}
},
),
_series() {
int? lastValidYValue;
List<CartesianSeries<dynamic, dynamic>> series = [];
series.add(SplineSeries<SomOverview, String>(
color: Colors.black,
width: 1.0,
dataSource: somData,
animationDuration: 0,
pointColorMapper: (SomOverview model, _) => hexToColor(model.somColor!),
xValueMapper: (SomOverview model, _) => model.minute,
yValueMapper: (SomOverview model, int idx) {
int bpm = double.parse(model.bpmAvg ?? "0.0").toInt();
if(bpm == 0) {
return lastValidYValue ?? 0;
} else {
lastValidYValue = bpm;
return bpm;
}
},
));
int? lastVal;
for (int index = 0;index<(somData.length-1);index++) {
series.add(SplineAreaSeries<SomOverview, String>(
color: Colors.black,
animationDuration: 0,
gradient: LinearGradient(colors: [hexToColor(somData[index].somColor ?? "#ffffff").withOpacity(0.8), hexToColor(somData[index].somColor ?? "#ffffff").withOpacity(0.0)], begin: Alignment.topCenter, end: Alignment.bottomCenter),
dataSource: [somData[index],somData[index+1]],
xValueMapper: (SomOverview model, _) => model.minute,
yValueMapper: (SomOverview model, _) {
int bpm = double.parse(model.bpmAvg ?? "0.0").toInt();
if(bpm == 0) {
return lastVal;
} else {
lastVal = bpm;
return bpm;
}
},
));
}
return series;
}
The text was updated successfully, but these errors were encountered: