我正在为 ASP.NET 4.0 Web 表单上的报告设计一个简单的图表。我面临的问题是,如果我使用任何程度的透明度,图表似乎会破坏字体。考虑下面的例子:
<asp:Chart
ID="chart" runat="server"
Height="300px" Width="300px"
BackColor="White"
ImageStorageMode="UseHttpHandler">
<Titles>
<asp:Title Name="title" Text="Results" />
</Titles>
<Legends>
<asp:Legend
Name="Default"
Docking="Top"
LegendStyle="Column"
BackColor="Transparent"
Title="Legend"
Font="Segoe UI, 10.25pt, style=Regular"
TitleFont="Segoe UI, 12pt, style=Regular">
</asp:Legend>
</Legends>
<Series>
<asp:Series
Name="Default"
ChartType="Pie"
CustomProperties="PieDrawingStyle=Concave,PieLabelStyle=Disabled"
IsValueShownAsLabel="False">
<Points>
<asp:DataPoint Label="Argentina" YValues="5" />
<asp:DataPoint Label="Italy" YValues="8" />
<asp:DataPoint Label="Portugal" YValues="12" />
<asp:DataPoint Label="China" YValues="45" />
<asp:DataPoint Label="United States" YValues="32" />
</Points>
</asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="area" BackColor="Transparent" />
</ChartAreas>
</asp:Chart>
为了演示,我对本示例中的数据点进行了硬编码。不需要隐藏代码。我的应用程序具有正确配置的 appSettings
和 system.webServer/modules
条目。请注意,图例的字体样式已明确设置为Regular
。
这会产生以下图表:
好的。现在来说说问题。我们要求图表位于具有渐变背景的 HTML 区域的顶部。为了避免中断渐变,我希望图表的背景区域是透明的。如果我将第四行从 BackColor="White"
更改为 BackColor="Transparent"
,我的所有字体都会变为粗体并失去抗锯齿功能。请参阅下文(图表位于灰色 div
中):
这是图表控件的限制吗?我可以制作一个具有透明背景并仍然具有优雅字体的图表吗?还是应该考虑其他选项(例如,探索其他图表框架或修改要求)?
最佳答案
将 AntiAliasing 属性设置为 Graphics 并检查它。我已经尝试了我的曲线图及其工作原理。
<asp:Chart
ID="chart"
runat="server"
Height="300px"
Width="300px"
BackColor="Transparent"
ImageStorageMode="UseHttpHandler"
AntiAliasing="Graphics">
关于asp.net - 如何通过 System.Web.UI.DataVisualization.Chart 使用透明度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18645883/