본문 바로가기

MFC

ChartDirector 한글 입력 문제 (ChartDirector Encoding)

차트를 그릴때 유용하게 사용할 수 있는 라이브러리 CharDirector(http://www.advsofteng.com/index.html)

다만.. 영어가 아닌 문자를 그래프에 사용할 경우, 유니코드로 변환 & 해당문자 사용가능 폰트로 변경해 주어야한다.


예제코드)



 wchar_t strUni[256] =L"유니코드";

 char title[256] = {0x00,};

 WideCharToMultiByte(CP_UTF8, 0, strUni, -1, title, sizeof(char)*255, 0, 0);


 double x[] = { 0, 1, 2 };

 double y[] = { 50, 100, 150 };


 // Create a XYChart object of size 250 x 250 pixels

 XYChart *c = new XYChart(250, 250);

 c->setDefaultFonts("gulim.ttc", "gulim.ttc");

 c->setPlotArea(30, 60, 200, 160);


 c->addTitle(title);

 LineLayer *layer = c->addLineLayer();

 layer->setXData(DoubleArray(x, 3));

 layer->addDataSet(DoubleArray(y, 3), 0xff0000, title);

 c->addLegend(30, 22);


 // Output the chart

 m_ChartViewer.setChart(c);


 delete c;


korean_helloworld.zip