PChart - 在 X 轴上显示固定数量的标签

发布于 2024-10-20 01:47:05 字数 160 浏览 8 评论 0原文

如何在 X 轴上仅显示固定数量的标签?

我尝试过“LabelSkip”,但我认为它仅适用于一定间隔,而不适用于固定数量的标签。

这是我的图表的打印屏幕: 在此处输入图像描述

How to show only a fixed number of labels in X-Axis ??

I have tried "LabelSkip", but I think it works only with an interval and not with fixed number of labels.

Here is a print-screen of my chart:
enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

神也荒唐 2024-10-27 01:47:05

您使用的是 pChart 1 还是 pChart2 ?

这可以在 pChart 1 中使用 setFixedScale 来实现。

要绘制最大值为 10、5 个点的比例,请在绘制比例之前使用以下命令

$Graph->setFixedScale(0,10,5);

Are you using pChart 1 or pChart2 ?

This can be achived in pChart 1 using setFixedScale

To draw a scale with a maximum value of 10 with 5 points use the following command before drawing the scale

$Graph->setFixedScale(0,10,5);
凌乱心跳 2024-10-27 01:47:05

我知道自从问这个问题以来已经有一段时间了,但这可能会对某人有所帮助:

$maxXLabels = 5; // How many labels on-screen?

$labelSkip = floor( count( $timestamp ) / $maxXLabels ); // how many should we skip?
$myPicture->drawScale(array("LabelSkip"=>$labelSkip));

I know it has been a while since this was asked, but it may help someone:

$maxXLabels = 5; // How many labels on-screen?

$labelSkip = floor( count( $timestamp ) / $maxXLabels ); // how many should we skip?
$myPicture->drawScale(array("LabelSkip"=>$labelSkip));
鲜肉鲜肉永远不皱 2024-10-27 01:47:05

我用过
“LabelSkip”=>(计数($系列)/ 10)
X 轴上有 10 个标签

对我来说效果很好

I have used
"LabelSkip"=>(count($series)/10)
to have 10 labels on the X axis

Works fine for me

蔚蓝源自深海 2024-10-27 01:47:05

乔尔·多伊彻的回答对我有用。我本来会投赞成票,但我对此没有足够的 stackoverflow 声誉。

它的工作原理正如他所说:图表宽度/MinDivHeight = 图表上的标签数量。

这是我的代码

$scaleSettings = array("DrawXLines"=>FALSE,"Mode"=>SCALE_MODE_START0,"GridR"=>0,"GridG"=>0,"GridB"=>0,"GridAlpha"=>10,"Pos"=>SCALE_POS_TOPBOTTOM, "MinDivHeight" => 50);

$pchart->chart->drawScale($scaleSettings);

Joel Deutscher's answer worked for me. I would have up voted it, but I do not have enough stackoverflow reputation for that.

It works exactly as he said: Chart Width / MinDivHeight = Number of labels on the chart.

Here's my code

$scaleSettings = array("DrawXLines"=>FALSE,"Mode"=>SCALE_MODE_START0,"GridR"=>0,"GridG"=>0,"GridB"=>0,"GridAlpha"=>10,"Pos"=>SCALE_POS_TOPBOTTOM, "MinDivHeight" => 50);

$pchart->chart->drawScale($scaleSettings);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文