Я пытаюсь настроить расстояние между осями Y, чтобы пользователь мог прочитать весь AxisTickLabel. Есть ли собственность или что-то, что я могу использовать?

Моя PlotModel выглядит примерно так:

C #:

  Plot = new PlotModel
  {
    Padding = new OxyThickness(0),
    DefaultColors = new List<OxyColor>
    {
      ColorPosition,
      ColorVelocity,
      ColorAcceleration
    },

    LegendOrientation = LegendOrientation.Vertical,
    LegendPlacement = LegendPlacement.Inside,
    LegendPosition = LegendPosition.TopRight,
    LegendBackground = OxyColor.FromAColor(200, OxyColors.White),
    LegendBorder = OxyColors.Black,
    PlotType = PlotType.XY
  };

  // YAxes
  _axisPosition = new LinearAxis
  {
    AxislineColor = ColorPosition,
    TicklineColor = ColorPosition,
    TextColor = ColorPosition,
    AxisTickToLabelDistance = 0,
    Position = AxisPosition.Left,
    Key = "position"
  };
  Plot.Axes.Add(_axisPosition);
  _seriesPosition = new LineSeries
  {
    Title = (string)converter.Convert(new object[] {"", "MotionProfilePosition"}, null, null, CultureInfo.CurrentCulture) + " [" + UnitItemPosition.ToString() + "]",
    YAxisKey = "position"

  };
  Plot.Series.Add(_seriesPosition);

  _axisVelocity = new LinearAxis
  {
    AxislineColor = ColorVelocity,
    TicklineColor = ColorVelocity,
    AxisTickToLabelDistance = 0,
    Position = AxisPosition.Left,
    TextColor = ColorVelocity,
    Key = "velocity"
  };
  Plot.Axes.Add(_axisVelocity);
  _seriesVelocity = new LineSeries
  {
    Title = (string)converter.Convert(new object[] {"", "MotionProfileVelocity"}, null, null, CultureInfo.CurrentCulture) + " [" + UnitItemVelocity.ToString() + "]",
    YAxisKey = "velocity"
  };
  Plot.Series.Add(_seriesVelocity);

  _axisAcceleration = new LinearAxis
  {
    AxislineColor = ColorAcceleration,
    TextColor = ColorAcceleration,
    AxisTickToLabelDistance = 0,
    Position = AxisPosition.Left,
    Key = "acceleration"
  };
  Plot.Axes.Add(_axisAcceleration);
  _seriesAcceleration = new LineSeries
  {
    Title = (string)converter.Convert(new object[] {"", "MotionProfileAcceleration"}, null, null, CultureInfo.CurrentCulture) + " [" + UnitItemAcceleration.ToString() + "]",
    YAxisKey = "acceleration"
  };
  Plot.Series.Add(_seriesAcceleration);


  // XAxis
  _axisTime = new LinearAxis
  {
    Position = AxisPosition.Bottom,
    Key = "time",
    Unit = UnitItemTime
  };
  Plot.Axes.Add(_axisTime);

XAML:

    <oxy:PlotView Grid.Row="0" Margin="0,0,0,15" Model="{Binding Plot, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}" Tag="{Binding Path=DataContext, ElementName=MotionControlMain}" Controller="{Binding Controller, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}" >
      <oxy:PlotView.ContextMenu>
        <ContextMenu DataContext="{Binding PlacementTarget.Tag, RelativeSource={RelativeSource Self}}">
          <MenuItem IsCheckable="True" Command="{Binding UpdatePlotCommand}"
                                  IsChecked="{Binding DisplayPosition}" 
                                  Foreground="{Binding ColorPosition, Converter={StaticResource OxyColorConverter}}">
            <MenuItem.Header>
              <MultiBinding Converter="{StaticResource LangConverter}">
                <Binding Path="SelectedLanguage" Mode="OneWay"/>
                <Binding>
                  <Binding.Source>MotionProfileMItemPos</Binding.Source>
                </Binding>
              </MultiBinding>
            </MenuItem.Header>
          </MenuItem>
          <MenuItem  IsCheckable="True" Command="{Binding UpdatePlotCommand}"
                                  IsChecked="{Binding DisplayVelocity}"
                                  Foreground="{Binding ColorVelocity, Converter={StaticResource OxyColorConverter}}">
            <MenuItem.Header>
              <MultiBinding Converter="{StaticResource LangConverter}">
                <Binding Path="SelectedLanguage" Mode="OneWay"/>
                <Binding>
                  <Binding.Source>MotionProfileMItemVelo</Binding.Source>
                </Binding>
              </MultiBinding>
            </MenuItem.Header>
          </MenuItem>
          <MenuItem  IsCheckable="True" Command="{Binding UpdatePlotCommand}"
                                  IsChecked="{Binding DisplayAcceleration}"
                                  Foreground="{Binding ColorAcceleration, Converter={StaticResource OxyColorConverter}}">
            <MenuItem.Header>
              <MultiBinding Converter="{StaticResource LangConverter}">
                <Binding Path="SelectedLanguage" Mode="OneWay"/>
                <Binding>
                  <Binding.Source>MotionProfileMItemAccel</Binding.Source>
                </Binding>
              </MultiBinding>
            </MenuItem.Header>
          </MenuItem>
          <MenuItem  IsCheckable="True" Command="{Binding UpdatePlotCommand}"
                                  IsChecked="{Binding DisplayJerk}" 
                                  Foreground="{Binding ColorJerk, Converter={StaticResource OxyColorConverter}}">
            
          <Separator/>
          <MenuItem Command="{Binding ResetPlotCommand}">
            <MenuItem.Header>
              <MultiBinding Converter="{StaticResource LangConverter}">
                <Binding Path="SelectedLanguage" Mode="OneWay"/>
                <Binding>
                  <Binding.Source>MotionProfileMItemReset</Binding.Source>
                </Binding>
              </MultiBinding>
            </MenuItem.Header>
          </MenuItem>
        </ContextMenu>
      </oxy:PlotView.ContextMenu>
    </oxy:PlotView>

Как пользователь, вы можете выбрать оси, которые хотите видеть, из заданных 3. Для более высоких TickLabelValues> 1000 значения трудно читать, поскольку они достигают следующей оси Y.

Скриншот Plotmodel

1
MKompressor 27 Окт 2020 в 13:33

1 ответ

Лучший ответ

enter image description here

PositionTier - это свойство, которое вы ищете. Вот код, который я использовал для создания этого изображения:

        PlotModel = new PlotModel();

        PlotModel.Axes.Add(new LinearAxis
        {
            Position = AxisPosition.Left,
            Title = "First",
            Minimum = 0,
            Maximum = 10000
        }) ;

        PlotModel.Axes.Add(new LinearAxis
        {
            Position = AxisPosition.Left,
            Title = "Second",
            Minimum = 0,
            Maximum = 10000,
            PositionTier = 1
        });

        PlotModel.Axes.Add(new LinearAxis
        {
            Position = AxisPosition.Left,
            Title = "Third",
            Minimum = 0,
            Maximum = 10000,
            PositionTier = 2
        });

        PlotModel.Axes.Add(new LinearAxis
        {
            Position = AxisPosition.Bottom,
            Title = "x"
        });
1
Đøharrrck 27 Окт 2020 в 12:44