سؤال

أنا مسح أجهزة الكمبيوتر واسعة النطاق لا يمكن أن يكون مثل 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);  

إذا قمت بتغيير القيمة التابعة إلى "المفتاح"، فهذا يعطي أخطاء غريبة مثل "جديد يجب استخدامه مع الاحتجاج أو العنصر، أو لم يتم تهيئة"

هل كانت مفيدة؟

المحلول

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); 
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top