简体   繁体   English

如何更改条形图中的文本

[英]how to change text in bar chart

how to change text in bar chart如何更改条形图中的文本

在此处输入图像描述

 List<_SalesData> data = [
    _SalesData(' 1', 3.1),
    _SalesData(' 2', 3.23),
    _SalesData(' 3', 3.39),
    _SalesData(' 4', 2.90),
    _SalesData(' 5', 3.80),
    _SalesData(' 6', 3.11),
    _SalesData(' 7', 3.81),
    _SalesData(' 8', 0)
  ];

how do I change the text in the barchart because the widget doesn't have text to change.我该如何更改条形图中的文本,因为小部件没有要更改的文本。 I don't know where to change this because I'm new to using charts, maybe someone here knows how to change it.我不知道在哪里更改它,因为我是使用图表的新手,也许这里有人知道如何更改它。 Thank you.谢谢你。

Center(
            child: SfCartesianChart(
              primaryXAxis: CategoryAxis(),
              // Chart title
              title: ChartTitle(
                text: 'IPK Mahasiswa',
                textStyle: bold6,
              ),
              tooltipBehavior: TooltipBehavior(enable: true),
              series: <ChartSeries<_SalesData, String>>[
                ColumnSeries(
                  color: primaryColor,
                  dataSource: data,
                  xValueMapper: (_SalesData sales, _) => sales.year,
                  yValueMapper: (_SalesData sales, _) => sales.sales,
                  dataLabelSettings: const DataLabelSettings(isVisible: true),
                ),
              ],
            ),
          ),

based on documentation: https://help.syncfusion.com/flutter/cartesian-charts/tooltip基于文档: https://help.syncfusion.com/flutter/cartesian-charts/tooltip

you can customize the tooltip您可以自定义工具提示

 _tooltipBehavior = TooltipBehavior(
                  enable: true, 
                  // Formatting the tooltip text
                  // customize here as you need
                  format: 'point.y%'
                );

there is some label format property:有一些 label 格式属性:

  • X value - point.x X 值 - point.x
  • Y value - point.y Y值point.y
  • Bubble size - point.size气泡大小 - point.size
  • Name of the series - series.name <- maybe this is what you need系列名称 - series.name <- 也许这就是你需要的

you can expolore more about it.您可以进一步了解它。

also you can use builder for custom widget: https://help.syncfusion.com/flutter/cartesian-charts/tooltip#tooltip-template您也可以使用自定义小部件的builderhttps://help.syncfusion.com/flutter/cartesian-charts/tooltip#tooltip-template

builder: (dynamic data, dynamic point, dynamic series,
      int pointIndex, int seriesIndex) {
        return Container(
           child: Text(
             'PointIndex : ${pointIndex.toString()}'
          )
       );

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM