doujiang2812 2019-06-13 19:33 采纳率: 0%
浏览 84
已采纳

pChart中的横坐标点位置 - 值,而不是标签

Using pChart to draw plot graphs:

$Data = new pData();
$Data->AddPoints(array(1,2,10), 'x');
$Data->AddPoints(array(6,8,3), 'y');
$Data->setAbscissa('x');

$Chart = new pImage($w, $h, $Data);
$Chart->setGraphArea(100, 0, $w-1, $h-50);  
$Chart->drawScale(array('Mode' => SCALE_MODE_FLOATING));
$Chart->drawPlotChart();    
$Chart->Stroke();

On the plot, the distance along the X axis from 1 to 2 is the same as the distance from 2 to 10. How do I make pChart interpret abscissa values as the numbers they are?

  • 写回答

2条回答 默认 最新

  • doulupian8725 2019-06-13 20:48
    关注

    I had a look into pChart code, and I'm almost sure that this is their only way to render data: X-axis ticks are spread evenly, number of ticks equals to number of data points in series.

    But you still can get what you want by defining some points as missing. In case of your specific example "fixed" code would look like this (the rest is unchanged):

    $Data->AddPoints(array(1,2,VOID,VOID,VOID,VOID,VOID,VOID,VOID,10), 'x');
    $Data->AddPoints(array(6,8,VOID,VOID,VOID,VOID,VOID,VOID,VOID,3), 'y');
    

    VOID is a constant defined somewhere within pData.class.php, so, you already have it available.

    And here is how end result looks like: https://imgur.com/a/Ae0nj0G ($w = 500; $h = 400;)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 宇视监控服务器无法登录
  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥15 DruidDataSource一直closing
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥50 power BI 从Mysql服务器导入数据,但连接进去后显示表无数据