我已經開發了ac#WPF應用程序 我想對我的圖表視圖執行縮放或滾動條,導致數據正在彼此合併,我相信縮放或添加滾動條會成爲解決方案。 到目前爲止,我有這個。順便說一句,我正在做一個柱形圖。如何將滾動條添加到圖表
public partial class ChartControl : UserControl
{
System.Windows.Forms.ScrollableControl ctl = new System.Windows.Forms.ScrollableControl();
public ChartControl()
{
InitializeComponent();
scrollbar();
}
private System.Windows.Forms.ScrollBars scrollbar()
{
if (ctl.HorizontalScroll.Visible)
return ctl.VerticalScroll.Visible ? System.Windows.Forms.ScrollBars.Both : System.Windows.Forms.ScrollBars.Horizontal;
else
return ctl.VerticalScroll.Visible ? System.Windows.Forms.ScrollBars.Vertical : System.Windows.Forms.ScrollBars.Horizontal;
}
private void Grid_MouseWheel(object sender, MouseWheelEventArgs e)
{
if (e.Delta > 0)
{
chartzoom.ScaleX += 1;
chartzoom.ScaleY += 1;
}
else
{
chartzoom.ScaleX -= 1;
chartzoom.ScaleY -= 1;
}
}
}
zoom是不是很有效,有沒有辦法給它添加一個滾動條或適當的縮放屬性。
XAML代碼如下::
<Grid MouseWheel="Grid_MouseWheel">
<dvc:Chart Canvas.Top="80" Name="chart" PreviewMouseWheel="Grid_MouseWheel" >
<dvc:Chart.LayoutTransform>
<ScaleTransform x:Name="chartzoom"></ScaleTransform>
</dvc:Chart.LayoutTransform>
<dvc:Chart.Series >
<dvc:ColumnSeries Title="{Binding LineGraphTitledg1}"
ItemsSource="{Binding Data}"
IndependentValueBinding="{Binding Path=Time}"
DependentValueBinding="{Binding Path=DG1}" />
<dvc:ColumnSeries Title="{Binding LineGraphTitledg2 }"
ItemsSource="{Binding Data}"
IndependentValueBinding="{Binding Path=Time}"
DependentValueBinding="{Binding Path=DG2}" />
<dvc:ColumnSeries Title="{Binding LineGraphTitledg3}"
ItemsSource="{Binding Data}"
IndependentValueBinding="{Binding Path=Time}"
DependentValueBinding="{Binding Path=DG3}" />
<dvc:ColumnSeries Title="{Binding LineGraphTitledgunits}"
ItemsSource="{Binding Dataunitvsfuel}"
IndependentValueBinding="{Binding Path=kwh}"
DependentValueBinding="{Binding Path=fuel}"
IsSelectionEnabled="True" />
</dvc:Chart.Series>
</dvc:Chart>
請向我們展示一些XAML代碼,特別是您定義圖表的XAML代碼。 –
@HermanCordes請參閱,因爲我已更新xaml。 – anilG