几何尺寸与公差论坛

 找回密码
 注册
查看: 1820|回复: 8

Live-Charts 绘制柱状图

  [复制链接]
发表于 2023-7-11 15:36:44 | 显示全部楼层 |阅读模式
 楼主| 发表于 2023-7-11 15:44:45 | 显示全部楼层
LiveCharts ColumnSeries在运行时更新颜色
https://www.it1352.com/1817191.html
private void ChangeThirdChartPointColorToRed()
  {
    CartesianMapper<double> mapper = Mappers.Xy<double>()
      .X((value, index) => index)
      .Y(value => value)
      .Fill((value, index) => index == 2 ? Brushes.Red : Brushes.Blue);

    // Dynamically set the third chart point color to red
    this.BlueSeries.Configuration = mapper;
  }
 楼主| 发表于 2023-7-11 15:46:01 | 显示全部楼层
resultControl.columnSeries.Configuration = Mappers.Xy<City>() .X((city, index) => index) .Y(city => city.Population) .Fill((city, index) =>
{ if (index % 2 == 0) { return System.Windows.Media.Brushes.Blue; } else { return System.Windows.Media.Brushes.Red; } });
 楼主| 发表于 2023-7-11 15:47:12 | 显示全部楼层
               resultControl.columnSeries.Configuration = Mappers.Xy<City>().X((city, index) => index).Y(city => city.Population).Fill((city, index) =>
                {
                    return resultControl.SearchDefectColor("", city.Name);
                });
 楼主| 发表于 2023-7-11 15:55:00 | 显示全部楼层
 楼主| 发表于 2023-7-11 16:01:48 | 显示全部楼层
更改LiveCharts中坐标轴标签的格式 - 成整数
https://www.it1352.com/772285.html
Func<double, string> Formatter = (x) => string.Format("{0:0}", x);
 楼主| 发表于 2023-7-11 16:07:36 | 显示全部楼层
    //        Mapper = Mappers.Xy<DefectData>()
    //.X((city, index) => index)
    //.Y(city => city.Population);
    //        List<City> Cities = new List<City>();
    //        Cities.Add(new City { Name = "Bejing", Population=1000 });
    //        Cities.Add(new City { Name = "Shenzhen", Population = 800 });
    //        Cities.Add(new City { Name = "Shanghai", Population = 900 });

    //        var records = Cities.OrderByDescending(x => x.Population).Take(3).ToArray();

            //Results = records.AsChartValues();
            //Labels = new ObservableCollection<string>(records.Select(x => x.Name));
 楼主| 发表于 2023-7-11 17:45:12 | 显示全部楼层
https://blog.csdn.net/Oneal5354/article/details/128272758
DataLabels        是否显示数据,即在柱状图上显示数值
 楼主| 发表于 2023-7-11 17:45:41 | 显示全部楼层
本帖最后由 wafer 于 2023-7-11 17:48 编辑

Live Charts (lvcharts.com)
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|几何尺寸与公差论坛

GMT+8, 2024-4-28 17:34 , Processed in 0.041844 second(s), 18 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表