Skip to content

怎样给曲线折线图 SplineSeries 的圆圈节点添加点击事件?  #137

@anfenglei9527

Description

@anfenglei9527
                                             SfCartesianChart(
                                                primaryXAxis: CategoryAxis(
                                                  isVisible: true,
                                                  //显示时间轴置顶
                                                  opposedPosition: false,
                                                  //时间轴反转
                                                  isInversed: false,
                                                ),
                                                primaryYAxis: NumericAxis(
                                                    labelFormat: '{value}%',
                                                    axisLine: AxisLine(
                                                        width: 0,
                                                        color: Colors
                                                            .transparent),
                                                    majorTickLines:
                                                        MajorTickLines(
                                                            color: Colors
                                                                .transparent)),
                                                //标题
                                                // title: ChartTitle(text: '折线图测试'),
                                                //选中类型
                                                selectionType:
                                                    SelectionType.series,
                                                //时间轴与值轴换位
                                                isTransposed: false,
                                                //选中手势
                                                selectionGesture:
                                                    ActivationMode
                                                        .singleTap,
                                                //图示
                                                legend: Legend(
                                                    isVisible: true,
                                                    iconHeight: 10,
                                                    iconWidth: 10,
                                                    //切换系列显示
                                                    toggleSeriesVisibility:
                                                        true,
                                                    //图示显示位置
                                                    position: LegendPosition
                                                        .bottom,
                                                    overflowMode:
                                                        LegendItemOverflowMode
                                                            .wrap,
                                                    //图示左右位置
                                                    alignment:
                                                        ChartAlignment
                                                            .center),
                                                //十字架
                                                crosshairBehavior:
                                                    CrosshairBehavior(
                                                  lineType: CrosshairLineType
                                                      .horizontal, //横向选择指示器
                                                  enable: true,
                                                  shouldAlwaysShow:
                                                      false, //十字架始终显示(横向选择指示器)
                                                  activationMode:
                                                      ActivationMode
                                                          .singleTap,
                                                ),
                                                //跟踪球
                                                trackballBehavior:
                                                    TrackballBehavior(
                                                  lineType: TrackballLineType
                                                      .vertical, //纵向选择指示器
                                                  activationMode:
                                                      ActivationMode
                                                          .singleTap,
                                                  enable: true,
                                                  tooltipAlignment:
                                                      ChartAlignment
                                                          .near, //工具提示位置(顶部)
                                                  shouldAlwaysShow:
                                                      true, //跟踪球始终显示(纵向选择指示器)
                                                  tooltipDisplayMode:
                                                      TrackballDisplayMode
                                                          .groupAllPoints, //工具提示模式(全部分组)
                                                ),
                                                //打开工具提示
                                                tooltipBehavior:
                                                    TooltipBehavior(
                                                  enable: true,
                                                  shared: true,
                                                  activationMode:
                                                      ActivationMode
                                                          .singleTap,
                                                ),

                                                //SplineSeries为曲线 LineSeries为折线ChartSeries
                                                series: <
                                                    ChartSeries<SalesData,
                                                        String>>[
                                                  SplineSeries<SalesData,
                                                      String>(
                                                    name: '已开',
                                                    dataSource:
                                                        attendanceweeklista,
                                                    xValueMapper:
                                                        (SalesData sales,
                                                                _) =>
                                                            sales.year,
                                                    yValueMapper:
                                                        (SalesData sales,
                                                                _) =>
                                                            sales.sales,
                                                    color: Color(
                                                        0xff3794F1), // 曲线 颜色设置
                                                    //显示数据标签
                                                    dataLabelSettings:
                                                        DataLabelSettings(
                                                      isVisible: true,
                                                      alignment:
                                                          ChartAlignment
                                                              .near,
                                                      labelAlignment:
                                                          ChartDataLabelAlignment
                                                              .auto,
                                                      textStyle:
                                                          ChartTextStyle(
                                                        fontSize: 14,
                                                      ),
                                                    ),
                                                    //修饰数据点(显示圆圈)
                                                    markerSettings:
                                                        MarkerSettings(
                                                            isVisible:
                                                                true),
                                                  ),
                                       
                                                ]),

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions