Skip to content

[Bug] ScatterSeries markers ignore 'color' attribute and default to white #2435

@gdzhujun

Description

@gdzhujun

Bug description

What was expected? : "The markers in the scatter plot should be rendered with the color specified in the ScatterSeries's color property (e.g., Colors.deepOrangeAccent)."
What happened? : "When setting the color property of a ScatterSeries to a specific color (e.g., Colors.deepOrangeAccent), the markers in the scatter plot are rendered as white instead of the specified color. This occurs even when animationDuration is set to 0 and pointColorMapper is null."

Steps to reproduce

1."Create a new Flutter project."
2."Add syncfusion_flutter_charts: ^31.1.19 to pubspec.yaml and run flutter pub get."
3."Replace the content of lib/main.dart with the Minimal Reproducible Example (MRE) code provided below."
4."Run the application"
5."Observe that the scatter plot markers are white instead of the expected color deep orange)."

Code sample

import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_charts/charts.dart';

void main() {
runApp(MyApp());
}

class MyApp extends StatelessWidget {
@OverRide
Widget build(BuildContext context) {
// 使用一个非常基础的 MaterialApp 和 ThemeData,不引入复杂的全局主题
return MaterialApp(
theme: ThemeData.light().copyWith( // 明确使用浅色主题
scaffoldBackgroundColor: Colors.grey[200], // 设置一个非纯白的背景,以便区分标记
),
home: ChartPage(),
);
}
}

// 定义数据模型
class SpeedTempConsumptionData {
SpeedTempConsumptionData(this.speed, this.temperature, [this.consumption]); // consumption 可选
final double speed;
final double temperature;
final double? consumption;
}

class ChartPage extends StatefulWidget {
@OverRide
_ChartPageState createState() => _ChartPageState();
}

class _ChartPageState extends State {
late List _chartData;

@OverRide
void initState() {
super.initState();
// 使用一些简单的硬编码数据
_chartData = [
SpeedTempConsumptionData(10, 25, 100),
SpeedTempConsumptionData(20, 26, 150),
SpeedTempConsumptionData(30, 27, 120),
SpeedTempConsumptionData(40, 28, 180),
SpeedTempConsumptionData(50, 29, 200),
SpeedTempConsumptionData(60, 30, 220),
];
}

@OverRide
Widget build(BuildContext context) {
print('Building MRE chart...');
return Scaffold(
appBar: AppBar(
title: Text('Syncfusion Scatter Color MRE'),
),
body: Center(
child: Container(
height: 400, // 给图表一个合理的尺寸
padding: EdgeInsets.all(16.0),
child: SfCartesianChart(
// 1. 设置一个与期望标记颜色有对比的背景色
backgroundColor: Colors.yellowAccent,

        primaryXAxis: NumericAxis(
          title: AxisTitle(text: 'Temperature (°C)'),
          edgeLabelPlacement: EdgeLabelPlacement.shift,
        ),
        primaryYAxis: NumericAxis(
          title: AxisTitle(text: 'Speed (km/h)'),
          edgeLabelPlacement: EdgeLabelPlacement.shift,
        ),
        series: <CartesianSeries<SpeedTempConsumptionData, num>>[
          ScatterSeries<SpeedTempConsumptionData, num>(
            // 2. 强制系列颜色为一个鲜明的颜色
            color: Colors.deepOrangeAccent, // 例如:深橙色

            // 3. 禁用动画,排除动画干扰
            animationDuration: 0,

            dataSource: _chartData,
            xValueMapper: (SpeedTempConsumptionData data, _) => data.temperature,
            yValueMapper: (SpeedTempConsumptionData data, _) => data.speed,

            // 4. 确保 pointColorMapper 为 null 或已移除
            pointColorMapper: null,

            // 5. 确保 markerSettings 中没有设置 color,或者 color 为 null
            markerSettings: MarkerSettings(
              isVisible: true,
              shape: DataMarkerType.rectangle,
              width: 20, // 足够大的标记以便看清颜色
              height: 20,
              borderWidth: 0, // 无边框
              // color: null, // 明确确保没有颜色设置或为 null
            ),
          )
        ],
      ),
    ),
  ),
);

}
}

Screenshots or Video

Image

Stack Traces

Stack Traces
[Add the Stack Traces here]

On which target platforms have you observed this bug?

iOS

Flutter Doctor output

[✓] Flutter (Channel stable, 3.35.1, on macOS 15.6.1 24G90 darwin-arm64, locale
zh-Hans-CN) [412ms]
• Flutter version 3.35.1 on channel stable at /Users/gdzhujun/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 20f8274939 (4 weeks ago), 2025-08-14 10:53:09 -0700
• Engine revision 1e9a811bf8
• Dart version 3.9.0
• DevTools version 2.48.0
• Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop,
enable-windows-desktop, enable-android, enable-ios, cli-animations,
enable-lldb-debugging

[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0)
[2.2s]
• Android SDK at /Users/gdzhujun/Library/Android/sdk
• Emulator version 36.1.9.0 (build_id 13823996) (CL:N/A)
• Platform android-36, build-tools 36.0.0
• Java binary at: /Applications/Android
Studio.app/Contents/jbr/Contents/Home/bin/java
This is the JDK bundled with the latest Android Studio installation on
this machine.
To manually set the JDK path, use: flutter config --jdk-dir="path/to/jdk".
• Java version OpenJDK Runtime Environment (build 21.0.7+-13880790-b1038.58)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.4) [915ms]
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 16F6
• CocoaPods version 1.16.2

[✓] Chrome - develop for the web [6ms]
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2025.1) [6ms]
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 21.0.7+-13880790-b1038.58)

[✓] Connected device (4 available) [5.9s]
• sdk gphone64 arm64 (mobile) • emulator-5554 •
android-arm64 • Android 16 (API 36) (emulator)
• iPhone 16 Pro (mobile) • D02C7854-E280-449D-8E95-8EE31A7AE831 • ios
• com.apple.CoreSimulator.SimRuntime.iOS-18-6 (simulator)
• macOS (desktop) • macos •
darwin-arm64 • macOS 15.6.1 24G90 darwin-arm64
• Chrome (web) • chrome •
web-javascript • Google Chrome 140.0.7339.133
! Error: Browsing on the local area network for jun的iPhone12. Ensure the
device is unlocked and attached with a cable or associated with the same
local area network as this Mac.
The device must be opted into Developer Mode to connect wirelessly. (code
-27)

[✓] Network resources [1,200ms]
• All expected network resources are available.

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    chartsCharts componentsolvedSolved the query using existing solutions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions