- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在尝试构建组合的散点图和折线图。目前散点图很好,当我添加线条时,它们向右旋转了 90 度,因此它们是垂直的而不是水平的。我一辈子都弄不明白为什么,所以如果有人有任何建议,那就太棒了。
下面的代码是完整的函数,忽略它的名称 - 现在不是样条图表(我真的应该改变它)。
function cg_graphs_spline_plot($surgeonname, $plotpoint, $nnotnullsingletotal, $surgeonplots, $baseline, $gsettings){
/*Build the binomial curve plots*/
$binomloop = $gsettings['maxmin'][0]['Max'] + 1;
for($i = 1; $i <= $binomloop; $i++){
$upperalert = cg_graphs_get_binomial($baseline, $i, 0.995);
$loweralert = cg_graphs_get_binomial($baseline, $i, 0.005);
$Ualert[] = ($upperalert['upper'] * 100);
$Lalert[] = ($loweralert['lower'] * 100);
//$upperalarm = cg_graphs_get_binomial($baseline, $i, 0.9995);
//$loweralarm = cg_graphs_get_binomial($baseline, $i, 0.0005);
//$Ualarm[] = ($upperalarm['upper'] * 100);
//$Lalarm[] = ($loweralarm['lower'] * 100);
}
unset($Ualert[0]); //delete the leading 0 value
unset($Lalert[0]); //delete the leading 0 value
mmi_watchdog('plotting alarm upper', '', $Ualert);
mmi_watchdog('plotting alarm lower', '', $Lalert);
//mmi_watchdog('plotting alarm upper', '', $Ualarm);
//mmi_watchdog('plotting alarm lower', '', $Lalarm);
/* Create the pData object */
$myData = new pData();
$myData->addPoints(array($plotpoint), "preSurgeons"); //Y pos just has to match pos of X
$myData->addPoints(array($nnotnullsingletotal), "pSurgeon"); //array pos matches, so the
foreach($surgeonplots['ops'] as $op){
$myData->addPoints($op, "Surgeons");
}
foreach($surgeonplots['reop'] as $reop){
$baselineplots[] = $baseline;
$myData->addPoints($reop, "reSurgeons");
}
$myData->addPoints($baselineplots, "baseline"); //add baseline for line graph
/** plot binomials */
$myData->addPoints($Ualert, "Ualert"); //add upper alert
$myData->addPoints($Lalert, "Lalert"); //add lower alert
//$myData->addPoints($Ualarm, "Ualarm"); //add upper alarm
//$myData->addPoints($Lalarm, "Lalarm"); //add lower alarm
/* Create the X axis and the binded series */
$myData->setSerieOnAxis("Surgeons",0);
$myData->setSerieOnAxis("pSurgeon",0);
$myData->setSerieOnAxis("Ualert",0);
$myData->setSerieOnAxis("Lalert",0);
$myData->setSerieOnAxis("baseline",0);
$myData->setAxisName(0,$gsettings['axisXlabel']); //Number of operations -- removed for now
$myData->setAxisXY(0,AXIS_X);
$myData->setAxisPosition(0,AXIS_POSITION_BOTTOM);
/* Create the Y axis and the binded series */
$myData->setSerieOnAxis("reSurgeons",1);
$myData->setSerieOnAxis("preSurgeons",1);
$myData->setAxisName(1,$gsettings['axisYlabel']);
$myData->setAxisXY(1,AXIS_Y);
$myData->setAxisUnit(1,"%");
$myData->setAxisPosition(1,AXIS_POSITION_LEFT);
/* Create All surgeons scatter chart binding */
$myData->setScatterSerie("Surgeons","reSurgeons",0);
$myData->setScatterSerieDescription(0,"All Surgeons");
$myData->setScatterSerieColor(0,array("R"=>255,"G"=>69,"B"=>0));
/* Create Single Surgions scatter point */
$myData->setScatterSerie("pSurgeon","preSurgeons",1);
$myData->setScatterSerieDescription(1, $surgeonname);
$myData->setScatterSerieColor(1,array("R"=>0,"G"=>191,"B"=>255));
/*unset the baseline for the first set*/
$myData->setSerieDrawable (array("baseline", "Ualert", "Lalert", "Ualarm", "Lalarm"), FALSE);
/* Create the pChart object */
$myPicture = new pImage(847,304,$myData);
$myPicture->drawGradientArea(0,0,847,304,DIRECTION_VERTICAL,array("StartR"=>47,"StartG"=>47,"StartB"=>47, "EndR"=>17,"EndG"=>17,"EndB"=>17,"Alpha"=>100));
$myPicture->drawGradientArea(0,250,847,304,DIRECTION_VERTICAL,array("StartR"=>47,"StartG"=>47,"StartB"=>47, "EndR"=>27,"EndG"=>27,"EndB"=>27,"Alpha"=>100));
$myPicture->drawLine(0,249,847,249,array("R"=>0,"G"=>0,"B"=>0));
$myPicture->drawLine(0,250,847,250,array("R"=>70,"G"=>70,"B"=>70));
/* Write the picture title */
$myPicture->setFontProperties(array("FontName"=>drupal_get_path('module', 'cg_graphs')."/pChart/fonts/pf_arma_five.ttf","FontSize"=>6));
$myPicture->setFontProperties(array("R"=>255,"G"=>255,"B"=>255));
$myPicture->drawText(423,14,$gsettings['title'],array("R"=>255,"G"=>255,"B"=>255,"Align"=>TEXT_ALIGN_MIDDLEMIDDLE));
/* Set the graph area */
$myPicture->setGraphArea(58,27,816,228);
/* Draw a rectangle */
$myPicture->drawFilledRectangle(57,27,816,228,array("R"=>0,"G"=>0,"B"=>0,"Dash"=>TRUE,"DashR"=>0, "DashG"=>51,"DashB"=>51,"BorderR"=>0,"BorderG"=>0,"BorderB"=>0));
/* Turn on shadow computing */
$myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>20));
/* Create the Scatter chart object */
$myScatter = new pScatter($myPicture,$myData);
/* Draw the scale */
$myScatter->drawScatterScale(array('LabelRotation' => 90, "Mode" => SCALE_MODE_MANUAL, "XMargin"=>4, "Pos" => SCALE_POS_LEFTRIGHT, "ManualScale" => $gsettings['maxmin'], 'Factors' => array(20)));
$myScatter->drawScatterLegend(640,266,array("Mode"=>LEGEND_VERTICAL ,"Style"=>LEGEND_NOBORDER, "Family"=>LEGEND_FAMILY_LINE));
/* Draw a scatter plot chart */
$myScatter->drawScatterPlotChart();
/*Draw Baseline chart*/
$myData->setSerieDrawable (array("pSurgeon", "Surgeons", "preSurgeons", "reSurgeons"), FALSE);
$myData->setSerieDrawable (array("baseline", "Ualert", "Lalert"), TRUE);
/* plot lines */
$myPicture->drawLineChart(array("DisplayValues"=>FALSE,"DisplayColor"=>DISPLAY_AUTO));
/* Write the 0 line */
$myPicture->drawThreshold(0,array("WriteCaption"=>TRUE));
/* Add a border to the picture */
$myPicture->drawRectangle(0,0,846,303,array("R"=>204,"G"=>204,"B"=>204));
$myData->setSerieDrawable (array("reSurgeons"), FALSE);
/* Set serie settings */
$myData->setSerieDescription("baseline","Average Baseline");
$myData->setSerieDescription("Ualert","Upper Alert Line");
$myData->setSerieDescription("Lalert","Lower Alert Line");
$myData->setSerieDescription("Ualarm","Upper Alarm Line");
$myData->setSerieDescription("Lalarm","Lower Alert Line");
$myPicture->drawLegend(540,266,array("Mode"=>LEGEND_VERTICAL ,"Style"=>LEGEND_NOBORDER, "Family"=>LEGEND_FAMILY_LINE));
/* Render the picture (choose the best way) */
$imagename = str_replace(' ', '-', $surgeonname);
$myPicture->render(drupal_get_path('module', 'cg_graphs')."/pChart/examples/pictures/".$imagename."-".$gsettings['name'].".png");
}
最佳答案
好吧,我想通了,我错过了线图的绘制比例。
新代码:
function cg_graphs_spline_plot($surgeonname, $plotpoint, $nnotnullsingletotal, $surgeonplots, $baseline, $gsettings){
/*Build the binomial curve plots*/
$binomloop = $gsettings['maxmin'][0]['Max'] + 1;
$x = 0;
for($i = 1; $i <= $binomloop; $i++){
$upperalert = cg_graphs_get_binomial($baseline, $i, 0.995);
$loweralert = cg_graphs_get_binomial($baseline, $i, 0.005);
$lineXaxis[] = $x; //build values for the line x axis
$baselineplots[] = $baseline; //build values for the baseline
$Ualert[] = ($upperalert['upper'] * 100);
$Lalert[] = ($upperalert['lower'] * 100);
$upperalarm = cg_graphs_get_binomial($baseline, $i, 0.9995);
$loweralarm = cg_graphs_get_binomial($baseline, $i, 0.0005);
$Ualarm[] = ($upperalarm['upper'] * 100);
$Lalarm[] = ($upperalarm['lower'] * 100);
$x++;
}
unset($Ualert[0]); //delete the leading 0 value
unset($Lalert[0]); //delete the leading 0 value
mmi_watchdog('plotting alarm upper', '', $Ualert);
mmi_watchdog('plotting alarm lower', '', $Lalert);
//mmi_watchdog('plotting alarm upper', '', $Ualarm);
//mmi_watchdog('plotting alarm lower', '', $Lalarm);
/* Create the pData object */
$myData = new pData();
$myData->addPoints(array($plotpoint), "preSurgeons"); //Y pos just has to match pos of X
$myData->addPoints(array($nnotnullsingletotal), "pSurgeon"); //array pos matches, so the
foreach($surgeonplots['ops'] as $op){
$myData->addPoints($op, "Surgeons");
}
foreach($surgeonplots['reop'] as $reop){
$myData->addPoints($reop, "reSurgeons");
}
$myData->addPoints($baselineplots, "baseline"); //add baseline for line graph
/** plot binomials */
$myData->addPoints($Ualert, "Ualert"); //add upper alert
$myData->addPoints($Lalert, "Lalert"); //add lower alert
$myData->addPoints($Ualarm, "Ualarm"); //add upper alarm
$myData->addPoints($Lalarm, "Lalarm"); //add lower alarm
/* Create the X axis and the binded series */
$myData->setSerieOnAxis("Surgeons",0);
$myData->setSerieOnAxis("pSurgeon",0);
$myData->setSerieOnAxis("Ualert",1);
$myData->setSerieOnAxis("Lalert",1);
$myData->setSerieOnAxis("baseline",1);
$myData->setAxisName(0,$gsettings['axisXlabel']); //Number of operations -- removed for now
$myData->setAxisXY(0,AXIS_X);
$myData->setAxisPosition(0,AXIS_POSITION_BOTTOM);
/* Create the Y axis and the binded series */
$myData->setSerieOnAxis("reSurgeons",1);
$myData->setSerieOnAxis("preSurgeons",1);
$myData->setAxisName(1,$gsettings['axisYlabel']);
$myData->setAxisXY(1,AXIS_Y);
$myData->setAxisUnit(1,"%");
$myData->setAxisPosition(1,AXIS_POSITION_LEFT);
/* Create All surgeons scatter chart binding */
$myData->setScatterSerie("Surgeons","reSurgeons",0);
$myData->setScatterSerieDescription(0,"All Surgeons");
$myData->setScatterSerieColor(0,array("R"=>255,"G"=>69,"B"=>0));
/* Create Single Surgions scatter point */
$myData->setScatterSerie("pSurgeon","preSurgeons",1);
$myData->setScatterSerieDescription(1, $surgeonname);
$myData->setScatterSerieColor(1,array("R"=>0,"G"=>191,"B"=>255));
/*unset the baseline for the first set*/
$myData->setSerieDrawable (array("baseline", "Ualert", "Lalert", "Ualarm", "Lalarm"), FALSE);
/* Create the pChart object */
$myPicture = new pImage(847,304,$myData);
$myPicture->drawGradientArea(0,0,847,304,DIRECTION_VERTICAL,array("StartR"=>47,"StartG"=>47,"StartB"=>47, "EndR"=>17,"EndG"=>17,"EndB"=>17,"Alpha"=>100));
$myPicture->drawGradientArea(0,250,847,304,DIRECTION_VERTICAL,array("StartR"=>47,"StartG"=>47,"StartB"=>47, "EndR"=>27,"EndG"=>27,"EndB"=>27,"Alpha"=>100));
$myPicture->drawLine(0,249,847,249,array("R"=>0,"G"=>0,"B"=>0));
$myPicture->drawLine(0,250,847,250,array("R"=>70,"G"=>70,"B"=>70));
/* Write the picture title */
$myPicture->setFontProperties(array("FontName"=>drupal_get_path('module', 'cg_graphs')."/pChart/fonts/pf_arma_five.ttf","FontSize"=>6));
$myPicture->setFontProperties(array("R"=>255,"G"=>255,"B"=>255));
$myPicture->drawText(423,14,$gsettings['title'],array("R"=>255,"G"=>255,"B"=>255,"Align"=>TEXT_ALIGN_MIDDLEMIDDLE));
/* Set the graph area */
$myPicture->setGraphArea(58,27,816,228);
/* Draw a rectangle */
$myPicture->drawFilledRectangle(57,27,816,228,array("R"=>0,"G"=>0,"B"=>0,"Dash"=>TRUE,"DashR"=>0, "DashG"=>51,"DashB"=>51,"BorderR"=>0,"BorderG"=>0,"BorderB"=>0));
/* Turn on shadow computing */
$myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>20));
/* Create the Scatter chart object */
$myScatter = new pScatter($myPicture,$myData);
/* Draw the scale */
$myScatter->drawScatterScale(array("Mode" => SCALE_MODE_MANUAL, "XMargin"=>4, "Pos" => SCALE_POS_LEFTRIGHT, "ManualScale" => $gsettings['maxmin'], 'Factors' => array(20)));
$myScatter->drawScatterLegend(640,266,array("Mode"=>LEGEND_VERTICAL ,"Style"=>LEGEND_NOBORDER, "Family"=>LEGEND_FAMILY_LINE));
/* Draw a scatter plot chart */
$myScatter->drawScatterPlotChart();
/*Draw Baseline chart*/
$myData->setSerieDrawable (array("pSurgeon", "Surgeons", "preSurgeons", "reSurgeons"), FALSE);
$myData->setSerieDrawable (array("baseline", "Ualert", "Lalert", "Ualarm", "Lalarm"), TRUE);
/* plot lines */
$myData->addPoints($lineXaxis,"Labels");
$myData->setSerieDescription("Labels","My labels");
$myData->setAbscissa("Labels");
$myPicture->drawScale(array("Mode" => SCALE_MODE_MANUAL, "XMargin"=>4, "Pos" => SCALE_POS_LEFTRIGHT, "ManualScale" => $gsettings['maxmin'], 'Factors' => array(20), 'RemoveXAxis' => TRUE));
$myPicture->drawLineChart(array("DisplayValues"=>FALSE,"DisplayColor"=>DISPLAY_AUTO));
/* Add a border to the picture */
$myPicture->drawRectangle(0,0,846,303,array("R"=>204,"G"=>204,"B"=>204));
/* Set serie settings */
$myData->setSerieDescription("baseline","Average Baseline");
$myData->setSerieDescription("Ualert","Upper Alert Line");
$myData->setSerieDescription("Lalert","Lower Alert Line");
$myData->setSerieDescription("Ualarm","Upper Alarm Line");
$myData->setSerieDescription("Lalarm","Lower Alert Line");
$myPicture->drawLegend(540,266,array("Mode"=>LEGEND_VERTICAL ,"Style"=>LEGEND_NOBORDER, "Family"=>LEGEND_FAMILY_LINE));
/* Render the picture (choose the best way) */
$imagename = str_replace(' ', '-', $surgeonname);
$myPicture->render(drupal_get_path('module', 'cg_graphs')."/pChart/examples/pictures/".$imagename."-".$gsettings['name'].".png");
}
关于php - Pchart - 错误轴上的折线图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16710037/
我希望我的 y 轴以 8 为间隔显示自动收报机。我已将缩放模式设置为手动,最小值为 0,最大值为 48,但它仍然默认为以 0 为间隔显示刻度5. 我还没有看到自定义的设置或选项,有没有办法做到这一点?
我正在用 p Chart 开发 php 饼图,看起来不错。现在我想改变每个切片的颜色。是否可以更改颜色? 最佳答案 您正在寻找的函数是 setSliceColor() - http://wiki.pc
有谁知道如何更改 pChart 中 x 轴标签的角度?我需要倾斜它们,以便在单个图表中显示更长的时间范围。 最佳答案 对于 pChart 2,可以使用 drawScale 方法的 'LabelRota
我的图表结果如下,我需要在轴名称或轴标签之间留出空格,这里需要在“月”和 x 轴标签之间留出一些空间,“点击次数”和 y 轴标签也类似。 最佳答案 尝试查找行号。 pDraw.class.php 中的
我正在尝试构建组合的散点图和折线图。目前散点图很好,当我添加线条时,它们向右旋转了 90 度,因此它们是垂直的而不是水平的。我一辈子都弄不明白为什么,所以如果有人有任何建议,那就太棒了。 下面的代码是
我在我的 php 页面中显示 3DPie 示例 pChart 时遇到问题,无论输出 (Stroke()、autoOutput()、render()) 是什么,它都不会呈现给浏览器,但示例在示例中有效文
我正在使用类似于此示例的雷达图: https://pchart.net/doc.draw.radar.html 我的数据范围从 1 分到 4 分,所以我配置了一些选项: $options = arra
我是 pchart 新手,在从 mysql 表创建图表时遇到问题(可能是我错过的问题)。我想要的只是根据我要选择的项目绘制一行图表。它只工作了一次,然后每次我尝试再次运行脚本时,apache(我使用的
我想使用 pChart 呈现样本值与日期的简单折线图。我已经掌握了基础知识,但如何处理日期中的空白?样本已按季度平均,但并非每个季度都有样本。有时它会跳过一两个季度。 目前,这些间隙在 X 轴上被一个
我正在使用以下内容: $chartImage->autoOutput('/statistics/'.$image.'.png'); 问题在于此代码将图像输出到浏览器。如果它将图像保存到具有我指定的目录
我正在尝试将一个方法的返回值分配给一个数组,然后在第二步中将该数组放入 pChart 的 addPoints() 方法中。 现在我正在使用以下代码: $dataUsage = array(); for
我尝试用 pchart 创建一个图表,我在这个链接(在官方网站)中做了这样的操作: https://wiki.pchart.net/doc.mysql.integration.html 但每次我都会收
我有一个名为“MonthReport.class.php”的类,它的结构如下所示: class MonthReport{ ..... //some member variabl
我正在使用 PChart 库,我想从 x 轴上的第 5 个索引开始绘制图表。有什么想法吗?我已经在这样做了: $myData->AddPoints(array("Jan","Feb","Mar","A
我正在尝试根据 pchart 提供的示例生成图表。这是我的代码: addPoints($Yes,"Yes"); $myData->addPoints($No,"No"); $myData->addPo
我有 RTM,但我真的不知道如何使用 strtotime 函数将日期从 UTC 转换为 unix 时间,因为我不确定哪些变量在哪里。具体代码如下: $value = $_POST["Attribute
我正在尝试将“pChart”与我的 PHP 代码集成。当我尝试运行示例时,它给我一个错误,指出 call to undefined function imagecreatetruecolor。建议的解
我是一名优秀的程序员,十分优秀!