求助大神
我用argetC1Chart.Actions.Add(new ZoomAction() { MouseButton = MouseButton.Left });在code behind 实现鼠标左键拖曳放大chart效果。 但是出现一个问题,就是放大到一定程度的时候chart的长度会自动改变。 我只需要放大X轴 不需要放大或显示Y轴。 找C1的客服问了好久也没得出个结论。我贴个sample上来。
XMAL:- <Window x:Class="CONECHART.MainWindow"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:System ="clr-namespace:System;assembly=mscorlib"
- xmlns:c1="http://schemas.componentone.com/winfx/2006/xaml"
- Title="MainWindow" Height="350" Width="525">
- <Grid>
- <c1:C1Chart Margin ="0,0,8,8" MinHeight ="160" MinWidth ="240" Content ="C1chart" ChartType="Bar" Name="TargetC1Chart" c1:BarColumnOptions.Size="1" Padding="10">
- <c1:C1Chart.Data>
- <c1:ChartData >
- <c1:ChartData.ItemNames>
- <x:Array Type="{x:Type System:String}">
- <System:String>Head Mixer</System:String>
- <System:String>Stand Mixer</System:String>
- <System:String>Can Opener</System:String>
- <System:String>Toaster</System:String>
- <System:String>Blender</System:String>
- <System:String>Food Processor</System:String>
- <System:String>Slow Cooker</System:String>
- <System:String>Microwave</System:String>
- </x:Array>
- </c1:ChartData.ItemNames>
- <c1:DataSeries Values="80 400 20 60 150 300 130 500" AxisX="Price" AxisY="Kitchen Elecronics" Label="Price"></c1:DataSeries>
- </c1:ChartData>
- </c1:C1Chart.Data>
- <c1:C1Chart.View>
- <c1:ChartView>
- <c1:ChartView.AxisX>
- <c1:Axis>
- <c1:Axis.ScrollBar>
- <c1:AxisScrollBar />
- </c1:Axis.ScrollBar>
- </c1:Axis>
- </c1:ChartView.AxisX>
- </c1:ChartView>
- </c1:C1Chart.View>
- </c1:C1Chart>
- </Grid>
- </Window>
复制代码
Code Behind:- using System.Windows;
- using System.Windows.Input;
- using C1.WPF.C1Chart;
- namespace CONECHART
- {
- /// <summary>
- /// Interaction logic for MainWindow.xaml
- /// </summary>
- public partial class MainWindow : Window
- {
- public MainWindow()
- {
- InitializeComponent();
- Init();
- }
- private void Init()
- {
- TargetC1Chart.Actions.Clear();
- TargetC1Chart.Actions.Add(new ZoomAction() { MouseButton = MouseButton.Left });
- }
- }
- }
复制代码
|