0
막대 차트 용 배열이 2 개 있습니다. $pm
및 $estimate
.차트 관리자에서 2 y 축을 동기화하는 방법
꺾은 선형 차트에 대한 값을 만들기위한 백분율에 대한 배열을 갖기 위해 $percent = ($estimate/$pm) * 100
을 계산 중입니다.
이제 바 차트와 내 라인 차트에서 내 2 y 축을 어떻게 동기화 할 수 있습니까?
여기에 내 코드
$transmonth = array(1, 2, 3);
$estimate = array(80, 50, 40);
$pm = array(10, 5, 8);
foreach($estimate as $k => $v){
$percent[$k] = ($pm[$k]/$v) * 100;
}
$data = $percent;
$data1 = $estimate;
$data2 = $pm;
$labels = $transmonth;
$c = new XYChart(780, 400, -1,1);
$c->addTitle("Mini-PM Hit Rate");
# Set the plotarea at (80, 40) and of 650, 300 pixels in size. Use alternating light
# grey (f8f8f8)/white (ffffff) background. Set border to transparent and use grey
# (CCCCCC) dotted lines as horizontal and vertical grid lines
$c->setPlotArea(80, 80, 650, 250, 0xffffff, 0xf8f8f8,Transparent, $c->dashLineColor(0xcccccc, Dotline), $c->dashLineColor(0xcccccc, Dotline));
$legendObj = $c->addLegend(70, 50, false, "arial.ttf", 10);
$legendObj->setBackground(Transparent);
$lineLayer = $c->addLineLayer2();
$lineLayerObj = $lineLayer->addDataSet($data, 0x009966, "Hit Rate Percentage");
$lineLayerObj->setDataSymbol(CircleShape, 9, 0xff9966, 0x009966);
$lineLayerObj->setDataLabelFormat("{value|1}");
$lineLayerObj->setDataLabelStyle("arialbd.ttf", 8);
$lineLayer->setLineWidth(2);
$lineLayer->setUseYAxis2();
$c->yAxis2->setLinearScale(0, 120, 10);
$layer = $c->addBarLayer2(Side);
$layer->addDataSet($data1, 0x10b4f1, "Estimated PM");
$layer->addDataSet($data2, 0x7B3BA3, "Actual PM");
$layer->setBorderColor(Transparent);
$layer->setBarGap(0.2, TouchBar);
$c->xAxis->setLabels($labels);
$c->xAxis->setTickOffset(0.5);
$c->xAxis->setTitle("Period");
$c->yAxis->setTitle("Total Handlers");
$c->yAxis2->setTitle("Hit Rate Percentage (%)");
header("Content-type: image/png");
print($c->makeChart2(PNG));
도와주세요입니다.
실제로 내 문제는 ........... 형제 어떻게 yaxis ..... 내 yaxis2 동기화 할 수 있습니다 ..... 내 yaxis2 종속 yaxis 종속 설정할 수 및 자동 조정 ... ... 내가 도와 줄 수 있니? ?????????? – elvis