0

我是 livechart 的新手,我在 livechart 中制作了以下基本图形。但是,我对此有两个疑问。

 using System;
    using System.Windows.Forms;
    using System.Windows.Media;
    using LiveCharts;
    using LiveCharts.Defaults;
    using LiveCharts.Wpf;

    namespace heatmap
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
                var converter = new System.Windows.Media.BrushConverter();
                var brush = (Brush)converter.ConvertFromString("#000000");
                var r = new Random();
                cartesianChart1.Series.Add(new HeatSeries
                { 
                    Values = new ChartValues<HeatPoint>
                    {

                        new HeatPoint(0, 0, 0.25),
                        new HeatPoint(0, 1, 0.5),
                        new HeatPoint(0, 2, 0.5),
                        new HeatPoint(0, 3, 1),


                        new HeatPoint(1, 0, 0.5),
                        new HeatPoint(1, 1, 0.5),
                        new HeatPoint(1, 2, 1),
                        new HeatPoint(1, 3, 0.5),

                        //"Robyn Williamson"
                        new HeatPoint(2, 0, 0.5),
                        new HeatPoint(2, 1, 1),
                        new HeatPoint(2, 2, 0.5),
                        new HeatPoint(2, 3, 0.5),


                        new HeatPoint(3, 0, 1),
                        new HeatPoint(3, 1, 0.5),
                        new HeatPoint(3, 2, 0.25),
                        new HeatPoint(3, 3, 0.25),



                    },
                    Fill=brush,
                    Stroke=brush,
                    Foreground = brush,
                    FontSize=20,
                    DataLabels = true,
                   // LabelPoint=val=>"hola",
                    //The GradientStopCollection is optional
                    //If you do not set this property, LiveCharts will set a gradient


                    GradientStopCollection = new GradientStopCollection
                    {
                       new GradientStop(Color.FromRgb(255, 255, 255), 0),
                        new GradientStop(Color.FromRgb(0, 255, 0), .25),
                        new GradientStop(Color.FromRgb(7, 193, 67), .5),
                        new GradientStop(Color.FromRgb(0, 128, 0), .75),
                        new GradientStop(Color.FromRgb(0, 60, 31), 1),


                    },


                });


                cartesianChart1.AxisX.Add(new Axis
                {
                    Position = AxisPosition.RightTop,
                    LabelsRotation = 0,
                    FontSize=15,
                    Labels = new[]
                    {
                        "variable rent",
                        "int tax.",
                        "Real state",
                        "money"
                    },
                    Separator = new Separator { Step = 1 }
                });

                cartesianChart1.AxisY.Add(new Axis
                {
                    FontSize = 15,
                    Labels = new[]
                    {
                        "Money",
                        "Real state",
                        "int tax",
                                             "variable rent"


                    }
                });

            }



            }
        }

输出: 在此处输入图像描述

  1. 如何反转渐变条的顺序?顶部为 1,底部为 0.25。

  2. 每个 HeatPoint 是否可以为每个标签放置工具提示或颜色(1 个标签白色和其他标签黄色)?

谢谢大家

4

0 回答 0