手动缩放 wpf 条形图

发布于 2024-08-09 14:41:39 字数 686 浏览 3 评论 0原文

我正在扫描计算机,它们的比例不能是 1.5,2,2.5,它们应该是整数,如 1,2,3,4。

我当前的代码是,

ICollection<KeyValuePair<String, int>> data = new Dictionary<String, int>();
            data.Add(new KeyValuePair<string, int>(Protocol, protocolCount));

            mycolseries = new ColumnSeries
                {
                    ItemsSource = data,
                    Title = Protocol,
                    IndependentValuePath = "Key",
                    DependentValuePath = "Value",                        
                };                
            mainChart.Series.Add(mycolseries);  

如果我将依赖值更改为“key”,它会给出奇怪的错误,例如“new 应该与调用或元素一起使用,或者尚未初始化”

I am scanning computers and their scale can not be like 1.5,2,2.5 they should be in whole numbers like 1,2,3,4.

my current code is

ICollection<KeyValuePair<String, int>> data = new Dictionary<String, int>();
            data.Add(new KeyValuePair<string, int>(Protocol, protocolCount));

            mycolseries = new ColumnSeries
                {
                    ItemsSource = data,
                    Title = Protocol,
                    IndependentValuePath = "Key",
                    DependentValuePath = "Value",                        
                };                
            mainChart.Series.Add(mycolseries);  

if i change dependent value to "key" it gives strange errors like "new should be used with the invocation or element, or has not been initialized"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空‖城人不在 2024-08-16 14:41:39
public void Window1(){
       setChartSCale()
}


private void setChartScale()
{
    lamainChart.Interval = 1;
    lamainChart.Orientation = AxisOrientation.Y;
    lamainChart.ShowGridLines = true;
    //lamainChart.Maximum = 50;
        lamainChart.Minimum = 0;
}

递归调用这个方法

private void addRecursiveLedgendAfterInit(string Protocol, int protocolCount)
{
      ICollection<KeyValuePair<String, int>> data = new Dictionary<String, int>();
      data.Add(new KeyValuePair<string, int>(Protocol, protocolCount));

      mycolseries = new ColumnSeries
      {
           ItemsSource = data,
           Title = Protocol,
           IndependentValuePath = "Key",                        
           DependentRangeAxis =lamainChart,
           DependentValuePath = "Value"
      };                
      mainChart.Series.Add(mycolseries); 
}
public void Window1(){
       setChartSCale()
}


private void setChartScale()
{
    lamainChart.Interval = 1;
    lamainChart.Orientation = AxisOrientation.Y;
    lamainChart.ShowGridLines = true;
    //lamainChart.Maximum = 50;
        lamainChart.Minimum = 0;
}

call this method recursivly

private void addRecursiveLedgendAfterInit(string Protocol, int protocolCount)
{
      ICollection<KeyValuePair<String, int>> data = new Dictionary<String, int>();
      data.Add(new KeyValuePair<string, int>(Protocol, protocolCount));

      mycolseries = new ColumnSeries
      {
           ItemsSource = data,
           Title = Protocol,
           IndependentValuePath = "Key",                        
           DependentRangeAxis =lamainChart,
           DependentValuePath = "Value"
      };                
      mainChart.Series.Add(mycolseries); 
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文