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

报告相同问题?

悬赏问题

  • ¥15 武汉岩海低应变分析软件,导数据库里不显示波形图
  • ¥15 CreateBitmapFromWicBitmap内存释放问题。
  • ¥30 win c++ socket
  • ¥30 CanMv K210开发板实现功能
  • ¥15 C# datagridview 栏位进度
  • ¥15 vue3页面el-table页面数据过多
  • ¥100 vue3中融入gRPC-web
  • ¥15 kali环境运行volatility分析android内存文件,缺profile
  • ¥15 写uniapp时遇到的问题
  • ¥15 vs 2008 安装遇到问题