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

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条)

报告相同问题?

悬赏问题

  • ¥50 开发板linux系统安装dpkg,apt函数库 有偿
  • ¥15 浏览器时间循环 交互事件和延时事件的 优先级与执行问题
  • ¥15 GD模块安装出错,libgd无法正常安装
  • ¥20 求有缘人帮我把笛卡尔坐标系转换为经纬度 有偿
  • ¥15 vue2中使用计算属性
  • ¥50 远程桌面打开Mastercam、没有许可证、物理机打开正常
  • ¥15 ubuntu安装gdal后java读取tif文件报错
  • ¥15 请问lammps怎么做两种金属连接的原子浓度分布图
  • ¥15 求jacquard数据集
  • ¥15 w10部分软件不能联网