I'm trying to use the ASP.NET chart controls for a website that is localised for number of languages. However, we've had issues with the charts when we recently added a Chinese localisation - all of the labels show squares where we actually want Chinese characters, as shown in my sample below (please note I don't know any Chinese so this could be saying anything):
default.aspx (no code behind):
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ChineseChart._Default" %>
<%@ Register Assembly="System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Chart runat="server" Height="270px" Palette="None" PaletteCustomColors="0, 192, 96; 0, 96, 48">
<legends>
<asp:Legend Alignment="Center" Docking="Bottom" Name="Legend1" BorderColor="Black">
</asp:Legend>
</legends>
<titles>
<asp:Title Name="Title1" Text="我的示例图表">
</asp:Title>
</titles>
<series><asp:Series Name="富" ChartType="Pie" Legend="Legend1">
<points>
<asp:DataPoint AxisLabel="酒吧" MapAreaAttributes="" ToolTip="" Url="" YValues="65" />
<asp:DataPoint AxisLabel="富开发者_如何转开发" MapAreaAttributes="" ToolTip="" Url="" YValues="24" />
</points>
</asp:Series>
</series>
<chartareas><asp:ChartArea Name="ChartArea1"></asp:ChartArea></chartareas>
</asp:Chart>
</div>
</form>
</body>
</html>
Chart Generated:
(source: simonrice.com)This to me points to a character encoding issue, but I can't find anything in the chart object to change the encoding of the control.
Is there any way I can fix this issue?
Update: We also have this website in Greek & Hebrew, & neither of these languages are causing us any issues on the charts.
If you don't have the non-Latin alphabet language packs, specifically Asian languages, installed on the computer, about the only readily available font that will display these characters is Arial Unicode MS.
The real downside to that font is that it looks like crap when displaying languages like English that use the Latin alphabet.
精彩评论