Search code examples
c#livecharts

Livecharts visible or hidden


I'm trying to use LiveCharts. I have a form where the user can select 1 or more (4) parameters.

When the user select 1 paramter, i draw 1 curve with 1 axis. But when 2 parameters are selected, i need 2 axis. This is only for the Y axis.

<lvc:CartesianChart.AxisY>
  <lvc:Axis Foreground="DodgerBlue" Title="" LabelFormatter="{Binding YFormatter}"/>
     <lvc:Axis Name="Axis2" Foreground="IndianRed" Title="" Position="RightTop" IsEnabled="False">
       <lvc:Axis.Separator>
           <lvc:Separator Style="{StaticResource CleanSeparator}"></lvc:Separator>
       </lvc:Axis.Separator>
     </lvc:Axis>
     <lvc:Axis Name="Axis3" Foreground="Black" Title="" Position="RightTop" IsEnabled="False" Visibility="Hidden">
        <lvc:Axis.Separator>
           <lvc:Separator Style="{StaticResource CleanSeparator}" ></lvc:Separator>
        </lvc:Axis.Separator>
     </lvc:Axis>
 </lvc:CartesianChart.AxisY>

I try to hide the axis and to disable it but i can't have 1 axis when i draw the curve for 1 parameter.

have you got an idea ?

Thanks in advance. Regards.


Solution

  • You can hide the labels (Axis.ShowLabels = false) and the separator (Axis.Separator.IsEnabled = false).

    <lvc:CartesianChart>
            <lvc:CartesianChart.AxisY>
                <lvc:Axis ShowLabels="False">
                    <lvc:Axis.Separator>
                        <lvc:Separator IsEnabled="False"></lvc:Separator>
                    </lvc:Axis.Separator>
                </lvc:Axis>
            </lvc:CartesianChart.AxisY>
        </lvc:CartesianChart>