我有一个带有lineseries和columnseries的图表。我添加了图例,它显示了两个空气泡。我如何给行和列命名-“症状”为行,“药物”为黄色条?它就像组:线表示症状严重程度,柱表示服用的药物量:
我尝试创建字符串列表ListNames并赋值给legend,但它不起作用。我的graph代码:
<chart:SfChart x:Name="barChart"
Margin="30,30,30,40"
HeightRequest="300">
<chart:SfChart.Legend>
<chart:ChartLegend DockPosition="Top"
OffsetY="-10"
Orientation="Horizontal"
ToggleSeriesVisibility="True"
Series="{Binding ListNames}">
<chart:ChartLegend.LabelStyle>
<chart:ChartLegendLabelStyle FontSize="15" />
</chart:ChartLegend.LabelStyle>
</chart:ChartLegend>
</chart:SfChart.Legend>
<chart:SfChart.PrimaryAxis>
<chart:DateTimeAxis LabelRotationAngle="-45"
RangePadding="RoundStart">
<chart:DateTimeAxis.LabelStyle>
<chart:ChartAxisLabelStyle LabelFormat="yyyy-MM-dd"
TextColor="gray">
</chart:ChartAxisLabelStyle>
</chart:DateTimeAxis.LabelStyle>
<chart:DateTimeAxis.Title>
<chart:ChartAxisTitle Text="Data"
TextColor="#7a7a7a" />
</chart:DateTimeAxis.Title>
</chart:DateTimeAxis>
</chart:SfChart.PrimaryAxis>
<chart:SfChart.SecondaryAxis>
<chart:NumericalAxis Minimum="1"
Maximum="11"
RangePadding="RoundStart">
<chart:NumericalAxis.Title>
<chart:ChartAxisTitle Text="Intensyvumas"
TextColor="#7a7a7a" />
</chart:NumericalAxis.Title>
</chart:NumericalAxis>
</chart:SfChart.SecondaryAxis>
<chart:ColumnSeries x:Name="ColumnSeriesSymptoms"
ItemsSource="{Binding MedicineDates}"
XBindingPath="Date"
YBindingPath="Dose"
EnableAnimation="true"
AnimationDuration="0.8">
</chart:ColumnSeries>
<chart:SplineSeries x:Name="SplineSeriesSymptoms2"
ItemsSource="{Binding SymptomDates2}"
XBindingPath="Date"
YBindingPath="Severity"
EnableAnimation="true"
AnimationDuration="0.8">
<chart:SplineSeries.YAxis>
<chart:NumericalAxis OpposedPosition="true"
Minimum="1"
Interval="2"
EdgeLabelsDrawingMode="Fit">
</chart:NumericalAxis>
</chart:SplineSeries.YAxis>
</chart:SplineSeries>
</chart:SfChart>
1条答案
按热度按时间ylamdve61#
要为图例中的行系列和列系列命名,可以使用每个系列的Label属性。下面,添加如何自定义图例以供参考:https://help.syncfusion.com/xamarin/charts/legend。请参考以下链接自定义图例项的外观:https://help.syncfusion.com/xamarin/charts/legend?cs-save-lang=1&cs-lang=xaml .
Chart image with legend
致上,
Sowndharya Selladurai。