Tôi đã tạo biểu đồ bằng bộ công cụ biểu đồ WPF (3.5) và tôi không thể hiển thị các trục y để hiển thị số nhỏ (ví dụ :001). Tôi đã đặt các giá trị nhỏ nhất và tối đa thành 0,001 và .009 tương ứng cho trục y và mặc dù biểu đồ đúng về mặt đồ họa, các nhãn phạm vi trục y hiển thị "0" hoặc "0,01". Tôi đoán rằng đây là một hạn chế của việc kiểm soát biểu đồ trong bộ công cụ 3,5 nhưng tôi hy vọng rằng tôi đang thiếu một cái gì đó. Dưới đây là một số mã ví dụ:Các nhãn trục công cụ lập biểu đồ WPF xuất hiện bằng 0 cho các số nhỏ
XAML:
<Window x:Class="WpfChartApplication.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525"
xmlns:chartingToolkit="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit">
<Grid>
<chartingToolkit:Chart Name="chart1">
<chartingToolkit:LineSeries
Title="Rates"
ItemsSource="{Binding Rates}"
IndependentValueBinding="{Binding Time}"
DependentValueBinding="{Binding Value}"
>
<chartingToolkit:LineSeries.DependentRangeAxis>
<chartingToolkit:LinearAxis
Orientation="Y"
Title="Y Value"
ShowGridLines="True"
Maximum=".009"
Minimum=".001"/>
</chartingToolkit:LineSeries.DependentRangeAxis>
</chartingToolkit:LineSeries>
<chartingToolkit:Chart.Axes>
<chartingToolkit:LinearAxis Orientation="X"
Title="X Value"
ShowGridLines="True"
/>
</chartingToolkit:Chart.Axes>
</chartingToolkit:Chart>
</Grid>
Và mã sau:
using System.Collections.Generic;
using System.Windows;
namespace WpfChartApplication
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
var cVm = new ChartViewModel();
chart1.DataContext = cVm;
}
}
public class ChartViewModel
{
public List<Rate> Rates { get; set; }
public ChartViewModel()
{
Rates = new List<Rate>();
Rates.Add(new Rate(1, .001));
Rates.Add(new Rate(2, .003));
Rates.Add(new Rate(3, .001));
Rates.Add(new Rate(4, .002));
Rates.Add(new Rate(5, .001));
Rates.Add(new Rate(6, .001));
Rates.Add(new Rate(7, .003));
Rates.Add(new Rate(8, .007));
Rates.Add(new Rate(9, .009));
Rates.Add(new Rate(10, .008));
}
}
public class Rate
{
public Rate(int time, double value)
{
Time = time;
Value = value;
}
public int Time { get; set; }
public double Value { get; set; }
}
}
Tôi ngạc nhiên đây không phải là hành vi mặc định để kiểm soát biểu đồ. Cảm ơn bạn đã giúp đỡ! –
@senor_cardgage không có probs :-) – punker76