Syncfusion Blazor 条形图与折线图
Syncfusion Blazor BarChart with LineChart
我正在使用 Syncfusion Blazor 条形图。我低于用线组合条形图的要求。有没有办法做到这一点?有线索吗?
我们可以使用图表组件中的列系列和线系列来实现您的要求(根据屏幕截图)。我们也准备了样张供大家参考。
示例 Link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/ColumnLineSeries1543449603.zip
代码段:
<SfChart Title="Hyaat Place Cedar Park 17-4-006" >
<ChartEvents OnAxisLabelRender="AxisLabelRender"></ChartEvents>
<ChartPrimaryXAxis ValueType="Syncfusion.Blazor.Charts.ValueType.Category" Interval="1">
<ChartAxisLabelStyle Color="transparent"></ChartAxisLabelStyle>
<ChartAxisLineStyle Width="0"></ChartAxisLineStyle>
<ChartAxisMajorTickLines Width="0"></ChartAxisMajorTickLines>
<ChartAxisMajorGridLines Width="0"></ChartAxisMajorGridLines>
</ChartPrimaryXAxis>
<ChartPrimaryYAxis >
<ChartAxisLineStyle Width="0"></ChartAxisLineStyle>
<ChartAxisMajorTickLines Width="0"></ChartAxisMajorTickLines>
</ChartPrimaryYAxis>
<ChartSeriesCollection>
<ChartSeries DataSource="@ChartPoints" Fill="#3864c6" XName="Country" YName="GoldMedal" Type="ChartSeriesType.Column">
</ChartSeries>
<ChartSeries DataSource="@ChartPoints" Fill="#85dba0" XName="Country" YName="SilverMedal" Type="ChartSeriesType.Column">
</ChartSeries>
<ChartSeries DataSource="@ChartPoints" Fill="#837fca" Width="3" XName="Country" YName="BronzeMedal" Type="ChartSeriesType.Line">
<ChartMarker Visible="true" Width="5" Height="5" Fill="#837fca">
</ChartMarker>
</ChartSeries>
</ChartSeriesCollection>
<ChartTooltipSettings Enable="true"></ChartTooltipSettings>
</SfChart>
// add your additional code here
public void AxisLabelRender(AxisLabelRenderEventArgs args)
{
if (args.Axis.Name == "PrimaryYAxis")
{
args.Text = "$"+ Convert.ToDouble(args.Text).ToString("N0");
}
}
截图:
我正在使用 Syncfusion Blazor 条形图。我低于用线组合条形图的要求。有没有办法做到这一点?有线索吗?
我们可以使用图表组件中的列系列和线系列来实现您的要求(根据屏幕截图)。我们也准备了样张供大家参考。
示例 Link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/ColumnLineSeries1543449603.zip
代码段:
<SfChart Title="Hyaat Place Cedar Park 17-4-006" >
<ChartEvents OnAxisLabelRender="AxisLabelRender"></ChartEvents>
<ChartPrimaryXAxis ValueType="Syncfusion.Blazor.Charts.ValueType.Category" Interval="1">
<ChartAxisLabelStyle Color="transparent"></ChartAxisLabelStyle>
<ChartAxisLineStyle Width="0"></ChartAxisLineStyle>
<ChartAxisMajorTickLines Width="0"></ChartAxisMajorTickLines>
<ChartAxisMajorGridLines Width="0"></ChartAxisMajorGridLines>
</ChartPrimaryXAxis>
<ChartPrimaryYAxis >
<ChartAxisLineStyle Width="0"></ChartAxisLineStyle>
<ChartAxisMajorTickLines Width="0"></ChartAxisMajorTickLines>
</ChartPrimaryYAxis>
<ChartSeriesCollection>
<ChartSeries DataSource="@ChartPoints" Fill="#3864c6" XName="Country" YName="GoldMedal" Type="ChartSeriesType.Column">
</ChartSeries>
<ChartSeries DataSource="@ChartPoints" Fill="#85dba0" XName="Country" YName="SilverMedal" Type="ChartSeriesType.Column">
</ChartSeries>
<ChartSeries DataSource="@ChartPoints" Fill="#837fca" Width="3" XName="Country" YName="BronzeMedal" Type="ChartSeriesType.Line">
<ChartMarker Visible="true" Width="5" Height="5" Fill="#837fca">
</ChartMarker>
</ChartSeries>
</ChartSeriesCollection>
<ChartTooltipSettings Enable="true"></ChartTooltipSettings>
</SfChart>
// add your additional code here
public void AxisLabelRender(AxisLabelRenderEventArgs args)
{
if (args.Axis.Name == "PrimaryYAxis")
{
args.Text = "$"+ Convert.ToDouble(args.Text).ToString("N0");
}
}
截图: