|
|
function ShowBarChart()
{
var ctrlman = m_Map.GetCtrlMan();
var ctrlstate = ctrlman.GetControlState();
var util = m_Map.GetUtility();
var posLL = ctrlstate.GetLLCenter(); // ÁöµµÀÇ Á᫐ ÁÂÇ¥
// Step 1. Get POI Manger
var poiman = ctrlman.GetPOIMan();
var baseman = poiman.CastToBaseManager();
// Step 2. Make POI Group
var group = poiman.FindGroup(100);
if (!group) group = poiman.NewGroup(100);
// Step 2-1. Make POI Style
var gstyle = poiman.FindStyle(1);
if (!gstyle)
{
gstyle = poiman.NewStyle(1); // -1: ¾ÆÀ̵ð ÀÚµ¿ »ý¼º
gstyle.SetGDIFont("±¼¸²", 0, 8);
gstyle.SetFontColor(util.RGBColor(0, 0, 0));
gstyle.SetFontOutColor(util.RGBColor(255, 255, 255));
gstyle.SetBrush(util.RGBColor(255, 255, 255), 0);
gstyle.SetPen(util.RGBColor(0, 0, 0), 1, 0);
}
group.SetStyle(gstyle);
var baritem = group.NewItem(-1);
baritem.SetLonLat(posLL._X, posLL._Y)
baritem.SetTextStyle(0x12)
baritem.SetCaption("BAR Chart")
baritem.SetContents("Contents\nHello")
var bar = baritem.CreateChart_Bar();
var r = Math.round(Math.random() * 255);
var g = Math.round(Math.random() * 255);
var b = Math.round(Math.random() * 255);
bar.SetBrush(util.RGBAColor(r,g,b,100));
bar.SetPen(util.RGBAColor(255,0,0,100), 1);
bar.SetMaxValue(100);
bar.SetMinValue(-100);
bar.SetHeight(80);
var maxcnt = Math.round(Math.random() * 5 + 2);
for (var i = 0; i < maxcnt; i++)
{
var barval = Math.round(Math.random() * 90 + 10);
r = Math.round(Math.random() * 255);
g = Math.round(Math.random() * 255);
b = Math.round(Math.random() * 255);
bar.AddData(-barval-100, 10, 5, util.RGBAColor(r,g,b,255), util.RGBAColor(0,0,0,255), 1);
bar.AddData(barval, 10, 5, util.RGBAColor(r,g,b,255), util.RGBAColor(0,0,0,255), 1);
}
alert(bar.GetMaxValue());
alert(bar.GetMinValue());
}
|
|
|
void CTestTalMapXDlg::ShowBarChart()
{
CXCtrlMan ctrlman = m_Map.GetCtrlMan();
CXControlState ctrlstate = ctrlman.GetControlState();
CXUtility util = m_Map.GetUtility();
CXPoint posLL = ctrlstate.GetLLCenter(); // ÁöµµÀÇ Á᫐ ÁÂÇ¥
// Step 1. Get POI Manger
CXPOIMan poiman = ctrlman.GetPOIMan();
CXPOIBaseMan baseman = poiman.CastToBaseManager();
// Step 2. Make POI Group
CXPOIGroup group = poiman.FindGroup(100);
if (!group) group = poiman.NewGroup(100);
// Step 2-1. Make POI Style
CXPOIStyle gstyle = poiman.FindStyle(1);
if (!gstyle)
{
gstyle = poiman.NewStyle(1); // -1: ¾ÆÀ̵ð ÀÚµ¿ »ý¼º
gstyle.SetGDIFont(_T("±¼¸²"), 0, 8);
gstyle.SetFontColor(util.RGBColor(0, 0, 0));
gstyle.SetFontOutColor(util.RGBColor(255, 255, 255));
gstyle.SetBrush(util.RGBColor(255, 255, 255), 0);
gstyle.SetPen(util.RGBColor(0, 0, 0), 1, 0);
}
group.SetStyle(gstyle);
CXPOIItem baritem = group.NewItem(-1);
baritem.SetLonLat(posLL.GetX(), posLL.GetY());
baritem.SetTextStyle(0x12);
baritem.SetCaption(_T("BAR Chart"));
baritem.SetContents(_T("Contents\nHello"));
CXMapChartBar bar = baritem.CreateChart_Bar(0);
int r = (double)rand() / (RAND_MAX + 1) * (255 - 0) + 0;
int g = (double)rand() / (RAND_MAX + 1) * (255 - 0) + 0;
int b = (double)rand() / (RAND_MAX + 1) * (255 - 0) + 0;
bar.SetBrush(util.RGBAColor(r,g,b,100));
bar.SetPen(util.RGBAColor(255,0,0,100), 1);
bar.SetMaxValue(100);
bar.SetMinValue(-100);
bar.SetHeight(80);
int maxcnt = rand() / (RAND_MAX + 1) * (10 - 5) + 5;
for (int i = 0; i < maxcnt; i++)
{
int barval = (double)rand() / (RAND_MAX + 1) * (200 - 50) + 50;
r = (double)rand() / (RAND_MAX + 1) * (255 - 0) + 0;
g = (double)rand() / (RAND_MAX + 1) * (255 - 0) + 0;
b = (double)rand() / (RAND_MAX + 1) * (255 - 0) + 0;
bar.AddData(-barval-100, 10, 5, util.RGBAColor(r,g,b,255), util.RGBAColor(0,0,0,255), 1);
bar.AddData(barval, 10, 5, util.RGBAColor(r,g,b,255), util.RGBAColor(0,0,0,255), 1);
}
CString strMinMaxValue(_T(""));
strMinMaxValue.Format(_T("Min : %f, Max : %f"), bar.GetMinValue(), bar.GetMaxValue());
AfxMessageBox(strMinMaxValue);
}
|
|