English 中文(简体)
活图——向第二轴增加数据
原标题:Live Charts - Adding data to the second Y axis

我拿着我的活海图,绘制了5种来自档案/空中港口的不同类型的数据,但这些数据都是在同一系列上。

我有2个Y轴线显示,但不能向每一方补充飞行数据。 活图文件是可怕的。

我已经建立了2个系列,但数据似乎并未确定。

<lvc:CartesianChart x:Name=“lc_MainChart” Hoverable=“False” Grid.Row=“0” Grid.Column=“1”, DisableAnimations=“True” ThuLocation=“Right” Loaded=“CartesianChart_Loaded” Margin=2,2,2,2,2”“Brush=“Black” 边界Thickness=”2,2,2,2,2,2,2”,2,2,2,2”

<lvc:CartesianChart.AxisX >
     <lvc:Axis Title="DATA POINTS" FontSize="18" MinValue="0" MaxValue="512" Labels="{Binding Labels}"></lvc:Axis>
</lvc:CartesianChart.AxisX>

<lvc:CartesianChart.AxisY>
     <lvc:Axis Title="MOTOR VOLTAGE (mV)" FontSize="18" MinValue="0" MaxValue="8000" ></lvc:Axis>
     <lvc:Axis Title="MOTOR CURRENT (mA)" FontSize="18" MinValue="0" MaxValue="800" Position="RightTop" ></lvc:Axis>
</lvc:CartesianChart.AxisY>

     <lvc:CartesianChart.Series>
          <lvc:LineSeries Name="Chart1" Values="{Binding ChartValues}"/>
          <lvc:LineSeries Name="Chart2" Values="{Binding ChartValues2}"/>
     </lvc:CartesianChart.Series>
</lvc:CartesianChart>

// Setup chart
ChartSeries = new SeriesCollection
{
    new LineSeries
    {
           Title = "Motor Current",
           Values = new ChartValues<Int16> {0},
           PointForeground = Brushes.Red,
           PointGeometry = null
    },
    new LineSeries
    {
           Title = "Voltage",
           Values = new ChartValues<Int16> {0},
           PointForeground = Brushes.Blue,
           PointGeometry = null
    }
};

// Setup chart series
ChartSeries2 = new SeriesCollection
{
    new LineSeries
    {
           Title = "Motor Speed",
           Values = new ChartValues<Int16> {0},
           PointForeground = Brushes.Green,
           PointGeometry = null
    },
    new LineSeries
    {
           Title = "Force",
           Values = new ChartValues<Int16> {0},
           PointForeground = Brushes.Blue,
           PointGeometry = null
    }
};

YFormatter = value => value.ToString("F");

lc_MainChart.LegendLocation = LegendLocation.Right;

ChartSeries[0].Values.Add(MotorCurrent[i]);
ChartSeries[1].Values.Add(VBat[i]);

ChartSeries2[0].Values.Add(MotorSpeed[i]);
ChartSeries2[1].Values.Add(Force[i]);

DataContext = this;
问题回答

这里的解决办法是:

<lvc:CartesianChart.Series>
      <lvc:LineSeries Name="Chart1" Values="{Binding ChartValues}" ScalesYAt="1"/>
      <lvc:LineSeries Name="Chart2" Values="{Binding ChartValues2}" ScalesYAt="0"/>
 </lvc:CartesianChart.Series>

just add ScalesYAt="[index of axis]" property to LineSerie, hope save your time.





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签