ExtJS 의 Chart 를 png / jpeg 로 내 보 내 중국어 난 장 판 해결
우 리 는 Chart 에서 chart 도 표를 그림 으로 내 보 낼 수 있 는 방법 이 있다 는 것 을 알 고 있다. 예 를 들 어: var chart=('Ext.chart.Chart',{...});chart.save({type: 'p_w_picpath/jpeg'});//jpeg 그림 으로 내 보 내 는 것 은 모든 영문 문자 데이터 에 대한 도표 입 니 다. 문제 가 없습니다.그러나 chart 에 중국어 문자 가 포함 되 어 있 으 면 내 보 낸 그림 에 오류 가 발생 하고 중국어 가 사각형 으로 표 시 됩 니 다 ( 네모 난 상 자 는 글꼴 설정 에 대응 하 는 인 코딩 이 없습니다. 물음표 입 니 다. 유 니 코드 - to - ANSI 는 지원 되 지 않 습 니 다. 물음표? 유 니 코드 를 코드 페이지 로 변환 하 는 데 실 패 했 기 때 문 입 니 다.)어 떡 하지?어 쩔 수 없 죠. 코드 를 추적 해 보 세 요. 다행히 EXTJS 문 서 는 괜 찮 네요.Ext. chart. Chart. save 의 원본 코드:
4. 567913. 관건 은 exporter 라 는 대상 인 것 같 습 니 다. 여기 서 ImageExporter 대상 이 분명 합 니 다. 그 속성 을 살 펴 보 니 defaultUrl 이 있 습 니 다.
"http://svg.sencha.io", save , , 、、 ??
chart , ??
,, 。。。 , : batik。 svg 。
spring mvc , controller svg :
@RequestMapping(value="/svg",method=RequestMethod.POST)
private void svgServer(HttpServletRequest request,HttpServletResponse response) throws IOException{
String svgString = request.getParameter("svg");
String type = request.getParameter("type");
response.setContentType(type);
String filename = new Date().toLocaleString().replace(" ","_")+"."+type.substring(6);
response.setHeader("Content-disposition","p_w_upload;filename=" + filename);
JPEGTranscoder t = new JPEGTranscoder();
t.addTranscodingHint(JPEGTranscoder.KEY_QUALITY,new Float(.8));
TranscoderInput input = new TranscoderInput(new StringReader(svgString));
try {
TranscoderOutput output = new TranscoderOutput(response.getOutputStream());
t.transcode(input, output);
response.getOutputStream().flush();
response.getOutputStream().close();
}catch (Exception e){
response.getOutputStream().close();
e.printStackTrace();
}
}
Ext.chart.Chart.save :
var mySave = function(surface, config) {
config = config || {};
var exportTypes = {
'p_w_picpath/png': 'Image',
'p_w_picpath/jpeg': 'Image',
'p_w_picpath/svg+xml': 'Svg'
},
prefix = exportTypes[config.type] || 'Svg',
exporter = Ext.draw.engine[prefix + 'Exporter'];
exporter.defaultUrl = '';
return exporter.generate(surface, config);
};
mySave(chart.surface,{
type: 'p_w_picpath/jpeg'
});
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
ExtJS2.2 트리의 종속 연결 선택프로젝트를 할 때 트리의 등급 연결 선택을 사용해야 합니다. 제 영향에서 ExtJs2.2는 자체 등급 연결 선택이 없는 것 같습니다.그리고 다음 코드가 있습니다....
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.