1- I 'm trying to implement a chart that is '
RangeColumnSeries' and I hided all datalabel and I want show datalabel of a column only when tap on and change color of this column also! is there ability to doing this.
2-I want add a custom "primaryXAxis". example I have chart between 1 to 400 and there is primaryXAxis every 100 amount and I want add custom line in 220 and 130 amount with custom color
how with example code . thanks
thanks very much. I will check it
Hello, Dharanitharan
have a nice day, I check your example and it's what I need to learn thanks,
but I have one question, how can show datalabel with same color of Series Color like options "useSeriesColor" in onDataLabelRender.
when tap on a bar and data label show but with background color same of series color, thanks
How Are you doing ?
Now, I'm facing some issues,
1- I want show datalabel in background color as series color .
2- if there more than series and tap on point in series one and stored index like 1 so in data render show all points in all series has index 1 .
I attached some image to show the idea
in number (1) I want make background for datalabel take same point color.
in number (2) in this image there are 3 series when tap on 1st point in 1st series all 1st points in others series show also.
|
onDataLabelRender: (DataLabelRenderArgs args) {
// Set the series color to the data label text color
args.textStyle = TextStyle(
fontSize: 14,
color: seriesIndex == 0
? _color1
: (seriesIndex == 1 ? _color2 : _color3));
} |
|
onDataLabelRender: (DataLabelRenderArgs args) {
if (index != null &&
index == args.pointIndex &&
seriesIndex != null &&
/// Checks whether the tapped series is equal to incoming series
_getSeriesName(seriesIndex!) ==
(args.seriesRenderer as ChartSeries).name) {
// Set the series color to the data label text color
args.textStyle = TextStyle(
fontSize: 14,
color: seriesIndex == 0
? _color1
: (seriesIndex == 1 ? _color2 : _color3));
if (seriesIndex == 0) {
args.text = args.text + ' mg/dl';
} else if (seriesIndex == 1) {
args.text = args.text + ' Carbs';
} else {
args.text = args.text + ' Units';
}
} else {
args.text = '';
}
},
onPointTapped: (PointTapArgs args) {
index = args.pointIndex;
// Set the tapped series index
seriesIndex = args.seriesIndex;
setState(() {});
},
|
thanks for your help ,
but about point number (1) I want make the background not font color like the next photo
Hello, Sriram Kiran .
thank you for you help ,
I have last question I hope :D
in "primaryXAxis" I noticed there isn't date is missing in some points , Please see the next image
the green line under some points there is missing date how can show date of every point.
|
SfCartesianChart(
primaryXAxis: DateTimeAxis(
// Interval type will be in minutes
intervalType: DateTimeIntervalType.minutes,
// Setting interval value as 2
interval: 2
)
) |
Hello , Sriram Kiran .
Unfortunately, I can't do what you said or it's not worked , so I have put snippet of my code, it's a widget that pass to a charts data and it's handle it and show. so please see it.
also see the what widget show at next image
1) I want show data label in background color with label of ChartData object like "67 mg/dl".
2) I want to show the data point only on the tapped series instead of all the series as dynamic due to I pass many series names every times different .
Thanks Sriram Kiran ,
I'm waiting this update
after update,
I'm still getting the same error when I enabled dataLabelMapper
I/flutter (30058): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter (30058): The following _CastError was thrown during paint():
I/flutter (30058): Null check operator used on a null value
I/flutter (30058):
I/flutter (30058): The relevant error-causing widget was:
I/flutter (30058): SfCartesianChart
I/flutter (30058): SfCartesianChart:file:///Volumes/Mac/Projects/flutter/jidaa/lib/ui-kit/charts/rangeBars.chart.dart:50:14
I/flutter (30058):
I/flutter (30058): When the exception was thrown, this was the stack:
I/flutter (30058): #0 _drawDataLabelRectAndText
I/flutter (30058): #1 drawDataLabel
I/flutter (30058): #2 DataLabelSettingsRenderer.renderDataLabel
I/flutter (30058): #3 _DataLabelPainter.paint
I/flutter (30058): #4 RenderCustomPaint._paintWithPainter
I/flutter (30058): #5 RenderCustomPaint.paint
I/flutter (30058): #6 RenderObject._paintWithContext
I/flutter (30058): #7 PaintingContext.paintChild
I/flutter (30058): #8 RenderBoxContainerDefaultsMixin.defaultPaint
I/flutter (30058): #9 RenderStack.paintStack
I/flutter (30058): #10 RenderStack.paint
I/flutter (30058): #11 RenderObject._paintWithContext
I/flutter (30058): #12 PaintingContext.paintChild
I/flutter (30058): #13 RenderProxyBoxMixin.paint
I/flutter (30058): #14 RenderDecoratedBox.paint
I/flutter (30058): #15 RenderObject._paintWithContext
I/flutter (30058): #16 PaintingContext.paintChild
I/flutter (30058): #17 RenderProxyBoxMixin.paint
I/flutter (30058): #18 RenderDecoratedBox.paint
I/flutter (30058): #19 RenderObject._paintWithContext
I/flutter (30058): #20 PaintingContext.paintChild
I/flutter (30058): #21 RenderProxyBoxMixin.paint
I/flutter (30058): #22 RenderObject._paintWithContext
I/flutter (30058): #23 PaintingContext.paintChild
I/flutter (30058): #24 RenderProxyBoxMixin.paint
I/flutter (30058): #25 RenderObject._paintWithContext
I/flutter (30058): #26 PaintingContext.paintChild
I/flutter (30058): #27 RenderProxyBoxMixin.paint
I/flutter (30058): #28 RenderObject._paintWithContext
I/flutter (30058): #29 PaintingContext.paintChild
I/flutter (30058): #30 RenderProxyBoxMixin.paint
I/flutter (30058): #31 RenderObject._paintWithContext
I/flutter (30058): #32 PaintingContext.paintChild
I/flutter (30058): #33 RenderProxyBoxMixin.paint
I/flutter (30058): #34 RenderObject._paintWithContext
I/flutter (30058): #35 PaintingContext.paintChild
I/flutter (30058): #36 RenderProxyBoxMixin.paint
I/flutter (30058): #37 RenderDecoratedBox.paint
I/flutter (30058): #38 RenderObject._paintWithContext
I/flutter (30058): #39 PaintingContext.paintChild
I/flutter (30058): #40 _RenderLayoutBuilder.paint
I/flutter (30058): #41 RenderObject._paintWithContext
I/flutter (30058): #42 PaintingContext.paintChild
I/flutter (30058): #43 RenderBoxContainerDefaultsMixin.defaultPaint
I/flutter (30058): #44 RenderFlex.paint
I/flutter (30058): #45 RenderObject._paintWithContext
I/flutter (30058): #46 PaintingContext.paintChild
I/flutter (30058): #47 _RenderLayoutBuilder.paint
I/flutter (30058): #48 RenderObject._paintWithContext
I/flutter (30058): #49 PaintingContext.paintChild
I/flutter (30058): #50 RenderBoxContainerDefaultsMixin.defaultPaint
I/flutter (30058): #51 RenderFlex.paint
I/flutter (30058): #52 RenderObject._paintWithContext
I/flutter (30058): #53 PaintingContext.paintChild
I/flutter (30058): #54 RenderShiftedBox.paint
I/flutter (30058): #55 RenderObject._paintWithContext
I/flutter (30058): #56 PaintingContext.paintChild
I/flutter (30058): #57 RenderShiftedBox.paint
I/flutter (30058): #58 RenderObject._paintWithContext
I/flutter (30058): #59 PaintingContext.paintChild
I/flutter (30058): #60 RenderProxyBoxMixin.paint
I/flutter (30058): #61 RenderDecoratedBox.paint
I/flutter (30058): #62 RenderObject._paintWithContext
I/flutter (30058): #63 PaintingContext.paintChild
I/flutter (30058): #64 RenderShiftedBox.paint
I/flutter (30058): #65 _ChartContainerBox.paint
I/flutter (30058): #66 RenderObject._paintWithContext
I/flutter (30058): #67 PaintingContext.paintChild
I/flutter (30058): #68 RenderProxyBoxMixin.paint
I/flutter (30058): #69 RenderObject._paintWithContext
I/flutter (30058): #70 PaintingContext._repaintCompositedChild
I/flutter (30058): #71 PaintingContext.repaintCompositedChild
I/flutter (30058): #72 PipelineOwner.flushPaint
I/flutter (30058): #73 RendererBinding.drawFrame
I/flutter (30058): #74 WidgetsBinding.drawFrame
I/flutter (30058): #75 RendererBinding._handlePersistentFrameCallback
I/flutter (30058): #76 SchedulerBinding._invokeFrameCallback
I/flutter (30058): #77 SchedulerBinding.handleDrawFrame
I/flutter (30058): #78 SchedulerBinding.scheduleWarmUpFrame.<anonymous closure>
I/flutter (30058): (elided 4 frames from class _RawReceivePortImpl, class _Timer, and dart:async-patch)
I/flutter (30058):
I/flutter (30058): The following RenderObject was being processed when the exception was fired: RenderCustomPaint#5f2fd relayoutBoundary=up1:
I/flutter (30058): creator: CustomPaint ← Container ← DataLabelRenderer ← Stack ← Container ← DecoratedBox ← Container
I/flutter (30058): ← DecoratedBox ← ConstrainedBox ← Container ← Listener ← _GestureSemantics ← ⋯
I/flutter (30058): parentData: not positioned; offset=Offset(0.0, 0.0) (can use size)
I/flutter (30058): constraints: BoxConstraints(0.0<=w<=341.4, 0.0<=h<=245.0)
I/flutter (30058): size: Size(0.0, 0.0)
I/flutter (30058): This RenderObject has no descendants.
I/flutter (30058): ════════════════════════════════════════════════════════════════════════════════════════════════════
Reloaded 1 of 2604 libraries in 2,656ms.
════════ Exception caught by rendering library ═════════════════════════════════
The following _CastError was thrown during paint():
Null check operator used on a null value
The relevant error-causing widget was
SfCartesianChart SfCartesianChart:file:///Volumes/Mac/Projects/flutter/jidaa/lib/ui-kit/charts/rangeBars.chart.dart:50:14
When the exception was thrown, this was the stack
#0 _drawDataLabelRectAndText
#1 drawDataLabel
#2 DataLabelSettingsRenderer.renderDataLabel
#3 _DataLabelPainter.paint
#4 RenderCustomPaint._paintWithPainter
#5 RenderCustomPaint.paint
#6 RenderObject._paintWithContext
#7 PaintingContext.paintChild
#8 RenderBoxContainerDefaultsMixin.defaultPaint
#9 RenderStack.paintStack
#10 RenderStack.paint
#11 RenderObject._paintWithContext
#12 PaintingContext.paintChild
#13 RenderProxyBoxMixin.paint
#14 RenderDecoratedBox.paint
#15 RenderObject._paintWithContext
#16 PaintingContext.paintChild
#17 RenderProxyBoxMixin.paint
#18 RenderDecoratedBox.paint
#19 RenderObject._paintWithContext
#20 PaintingContext.paintChild
#21 RenderProxyBoxMixin.paint
#22 RenderObject._paintWithContext
#23 PaintingContext.paintChild
#24 RenderProxyBoxMixin.paint
#25 RenderObject._paintWithContext
#26 PaintingContext.paintChild
#27 RenderProxyBoxMixin.paint
#28 RenderObject._paintWithContext
#29 PaintingContext.paintChild
#30 RenderProxyBoxMixin.paint
#31 RenderObject._paintWithContext
#32 PaintingContext.paintChild
#33 RenderProxyBoxMixin.paint
#34 RenderObject._paintWithContext
#35 PaintingContext.paintChild
#36 RenderProxyBoxMixin.paint
#37 RenderDecoratedBox.paint
#38 RenderObject._paintWithContext
#39 PaintingContext.paintChild
#40 _RenderLayoutBuilder.paint
#41 RenderObject._paintWithContext
#42 PaintingContext.paintChild
#43 RenderBoxContainerDefaultsMixin.defaultPaint
#44 RenderFlex.paint
#45 RenderObject._paintWithContext
#46 PaintingContext.paintChild
#47 _RenderLayoutBuilder.paint
#48 RenderObject._paintWithContext
#49 PaintingContext.paintChild
#50 RenderBoxContainerDefaultsMixin.defaultPaint
#51 RenderFlex.paint
#52 RenderObject._paintWithContext
#53 PaintingContext.paintChild
#54 RenderShiftedBox.paint
#55 RenderObject._paintWithContext
#56 PaintingContext.paintChild
#57 RenderShiftedBox.paint
#58 RenderObject._paintWithContext
#59 PaintingContext.paintChild
#60 RenderProxyBoxMixin.paint
#61 RenderDecoratedBox.paint
#62 RenderObject._paintWithContext
#63 PaintingContext.paintChild
#64 RenderShiftedBox.paint
#65 _ChartContainerBox.paint
#66 RenderObject._paintWithContext
#67 PaintingContext.paintChild
#68 RenderProxyBoxMixin.paint
#69 RenderObject._paintWithContext
#70 PaintingContext._repaintCompositedChild
#71 PaintingContext.repaintCompositedChild
#72 PipelineOwner.flushPaint
#73 RendererBinding.drawFrame
#74 WidgetsBinding.drawFrame
#75 RendererBinding._handlePersistentFrameCallback
#76 SchedulerBinding._invokeFrameCallback
#77 SchedulerBinding.handleDrawFrame
#78 SchedulerBinding.scheduleWarmUpFrame.<anonymous closure>
(elided 4 frames from class _RawReceivePortImpl, class _Timer, and dart:async-patch)
The following RenderObject was being processed when the exception was fired: RenderCustomPaint#5f2fd relayoutBoundary=up1
RenderObject: RenderCustomPaint#5f2fd relayoutBoundary=up1
parentData: not positioned; offset=Offset(0.0, 0.0) (can use size)
constraints: BoxConstraints(0.0<=w<=341.4, 0.0<=h<=245.0)
size: Size(0.0, 0.0)
════════════════════════════════════════════════════════════════════════════════
Hello,
I have found an issue I think it's from package
when add
and when use
I faced this error
I/flutter (23746): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter (23746): The following RangeError was thrown during paint():
I/flutter (23746): RangeError (index): Invalid value: Not in inclusive range 0..6: 7
I/flutter (23746):
I/flutter (23746): The relevant error-causing widget was:
I/flutter (23746): SfCartesianChart
I/flutter (23746):
I/flutter (23746):
I/flutter (23746): When the exception was thrown, this was the stack:
I/flutter (23746): #0 List.[] (dart:core-patch/growable_array.dart:254:60)
I/flutter (23746): #1 calculateDataLabelPosition
I/flutter (23746): #2 DataLabelSettingsRenderer.renderDataLabel
I/flutter (23746): #3 _DataLabelPainter.paint
I/flutter (23746): #4 RenderCustomPaint._paintWithPainter
I/flutter (23746): #5 RenderCustomPaint.paint
I/flutter (23746): #6 RenderObject._paintWithContext
I/flutter (23746): #7 PaintingContext.paintChild
I/flutter (23746): #8 RenderBoxContainerDefaultsMixin.defaultPaint
I/flutter (23746): #9 RenderStack.paintStack
I/flutter (23746): #10 RenderStack.paint
I/flutter (23746): #11 RenderObject._paintWithContext
I/flutter (23746): #12 PaintingContext.paintChild
I/flutter (23746): #13 RenderProxyBoxMixin.paint
I/flutter (23746): #14 RenderDecoratedBox.paint
I/flutter (23746): #15 RenderObject._paintWithContext
I/flutter (23746): #16 PaintingContext.paintChild
I/flutter (23746): #17 RenderProxyBoxMixin.paint
I/flutter (23746): #18 RenderDecoratedBox.paint
I/flutter (23746): #19 RenderObject._paintWithContext
I/flutter (23746): #20 PaintingContext.paintChild
I/flutter (23746): #21 RenderProxyBoxMixin.paint
I/flutter (23746): #22 RenderObject._paintWithContext
I/flutter (23746): #23 PaintingContext.paintChild
I/flutter (23746): #24 RenderProxyBoxMixin.paint
I/flutter (23746): #25 RenderObject._paintWithContext
I/flutter (23746): #26 PaintingContext.paintChild
I/flutter (23746): #27 RenderProxyBoxMixin.paint
I/flutter (23746): #28 RenderObject._paintWithContext
I/flutter (23746): #29 PaintingContext.paintChild
I/flutter (23746): #30 RenderProxyBoxMixin.paint
I/flutter (23746): #31 RenderObject._paintWithContext
I/flutter (23746): #32 PaintingContext.paintChild
I/flutter (23746): #33 RenderProxyBoxMixin.paint
I/flutter (23746): #34 RenderObject._paintWithContext
I/flutter (23746): #35 PaintingContext.paintChild
I/flutter (23746): #36 RenderProxyBoxMixin.paint
I/flutter (23746): #37 RenderDecoratedBox.paint
I/flutter (23746): #38 RenderObject._paintWithContext
I/flutter (23746): #39 PaintingContext.paintChild
I/flutter (23746): #40 _RenderLayoutBuilder.paint
I/flutter (23746): #41 RenderObject._paintWithContext
I/flutter (23746): #42 PaintingContext.paintChild
I/flutter (23746): #43 RenderBoxContainerDefaultsMixin.defaultPaint
I/flutter (23746): #44 RenderFlex.paint
I/flutter (23746): #45 RenderObject._paintWithContext
I/flutter (23746): #46 PaintingContext.paintChild
I/flutter (23746): #47 _RenderLayoutBuilder.paint
I/flutter (23746): #48 RenderObject._paintWithContext
I/flutter (23746): #49 PaintingContext.paintChild
I/flutter (23746): #50 RenderBoxContainerDefaultsMixin.defaultPaint
I/flutter (23746): #51 RenderFlex.paint
I/flutter (23746): #52 RenderObject._paintWithContext
I/flutter (23746): #53 PaintingContext.paintChild
I/flutter (23746): #54 RenderShiftedBox.paint
I/flutter (23746): #55 RenderObject._paintWithContext
I/flutter (23746): #56 PaintingContext.paintChild
I/flutter (23746): #57 RenderShiftedBox.paint
I/flutter (23746): #58 RenderObject._paintWithContext
I/flutter (23746): #59 PaintingContext.paintChild
I/flutter (23746): #60 RenderProxyBoxMixin.paint
I/flutter (23746): #61 RenderDecoratedBox.paint
I/flutter (23746): #62 RenderObject._paintWithContext
I/flutter (23746): #63 PaintingContext.paintChild
I/flutter (23746): #64 RenderShiftedBox.paint
I/flutter (23746): #65 _ChartContainerBox.paint
I/flutter (23746): #66 RenderObject._paintWithContext
I/flutter (23746): #67 PaintingContext.paintChild
I/flutter (23746): #68 RenderProxyBoxMixin.paint
I/flutter (23746): #69 RenderObject._paintWithContext
I/flutter (23746): #70 PaintingContext._repaintCompositedChild
I/flutter (23746): #71 PaintingContext.repaintCompositedChild
I/flutter (23746): #72 PipelineOwner.flushPaint
I/flutter (23746): #73 RendererBinding.drawFrame
I/flutter (23746): #74 WidgetsBinding.drawFrame
I/flutter (23746): #75 RendererBinding._handlePersistentFrameCallback
I/flutter (23746): #76 SchedulerBinding._invokeFrameCallback
I/flutter (23746): #77 SchedulerBinding.handleDrawFrame
I/flutter (23746): #78 SchedulerBinding.scheduleWarmUpFrame.<anonymous closure>
I/flutter (23746): (elided 4 frames from class _RawReceivePortImpl, class _Timer, and dart:async-patch)
I/flutter (23746):
I/flutter (23746): The following RenderObject was being processed when the exception was fired: RenderCustomPaint#b9a6e relayoutBoundary=up1:
I/flutter (23746): creator: CustomPaint ← Container ← DataLabelRenderer ← Stack ← Container ← DecoratedBox ← Container
I/flutter (23746): ← DecoratedBox ← ConstrainedBox ← Container ← Listener ← _GestureSemantics ← ⋯
I/flutter (23746): parentData: not positioned; offset=Offset(0.0, 0.0) (can use size)
I/flutter (23746): constraints: BoxConstraints(0.0<=w<=341.4, 0.0<=h<=288.2)
I/flutter (23746): size: Size(0.0, 0.0)
I/flutter (23746): This RenderObject has no descendants.
I/flutter (23746): ════════════════════════════════════════════════════════════════════════════════════════════════════
Reloaded 1 of 2741 libraries in 5,087ms.
Thanks Yuvaraj Gajaraj ,
I'm waiting for this fix.