打开 Flash 图表 - 工具提示 #x_label# 未显示

发布于 2024-09-08 18:50:30 字数 1078 浏览 4 评论 0原文

我目前正在使用 PHP 通过 Open Flash Charts(我相信版本 1,可能是版本 2...)实现的条形图。不幸的是,我们遇到了真正的麻烦,工具提示没有显示正确的内容。我试图让它显示悬停列的 x 轴标签,然后是“:”,然后是条的值。代码如下:

$Colour = '#3465A4';

$BarChart= new bar();
$BarChart->set_values($Bar);
$BarChart->set_colour($Colour);
$BarChart->set_tooltip('#x_label#:#val#');

$x_labels = new x_axis_labels();
$x_labels->set_labels($Roles);
$x_labels->rotate(-60);

$x = new x_axis();
$x->set_labels($x_labels);

$chart = new open_flash_chart();
$chart->add_element($BarChart);
$chart->set_bg_colour( '#FFFFFF' ); 
$chart->set_x_axis($x); 

$tooltip = new tooltip();
$tooltip->set_hover();

$chart->set_tooltip($tooltip);

$JSONArray['my_chart_1'] = $chart->toPrettyString();

据我所知,这应该是正确的 - 条形图出现,并具有正确的值(从 $bar 填充,其生成未在上面显示)。但是,列的悬停工具提示仅显示“:值” - 缺少标签名称!

有谁知道我们可能哪里出了问题,以及我该如何修复它?

编辑:

为任何前来尝试回答此问题的赏金猎人提供更新。我没有接受以下答案的原因是它只提供了解决方法,并没有解释为什么需要解决方法。我正在寻找我最初问题的答案(如何使标签显示在正常条形图中),或者寻找关于为什么必须使用堆积条形图的合理解释(包括来源你的答案好多了!)。如果是后者,示例代码或如何创建堆叠图表的解释也将非常感激!

I'm currently playing with a bar chart implemented through Open Flash Charts (I believe version 1, might be version 2...) with PHP. Unfortunately, we're having real trouble with the tooltip not showing the correct thing. I am trying to get it to show the x-axis label for the hovered-over column, then a ":", then the value of the bar. The code is as follows:

$Colour = '#3465A4';

$BarChart= new bar();
$BarChart->set_values($Bar);
$BarChart->set_colour($Colour);
$BarChart->set_tooltip('#x_label#:#val#');

$x_labels = new x_axis_labels();
$x_labels->set_labels($Roles);
$x_labels->rotate(-60);

$x = new x_axis();
$x->set_labels($x_labels);

$chart = new open_flash_chart();
$chart->add_element($BarChart);
$chart->set_bg_colour( '#FFFFFF' ); 
$chart->set_x_axis($x); 

$tooltip = new tooltip();
$tooltip->set_hover();

$chart->set_tooltip($tooltip);

$JSONArray['my_chart_1'] = $chart->toPrettyString();

As far as I can tell, this should be correct - the bar chart appears, with the correct values (populated from $bar, whose generation is not shown above). However, the hover-over tool-tip for a column only shows ":value" - the label name is missing!

Does anyone know where we might have gone wrong, and how I can fix it?

EDIT:

An update for any Bounty Hunters coming in to try and answer this question. The reason I have not accepted the below answer is that it only provides a work-around, and does not explain why the work-around is necessary. I am looking either for an answer to my original question (how to make the labels show in a normal bar-chart), or a reasonable explanation regarding why one must use a stacked bar chart (including sources makes your answer so much better!). If the latter, example code or an explanation of how stacked charts are created would be much appreciated as well!

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

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

发布评论

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

评论(2

寒江雪… 2024-09-15 18:50:30

如果您对简单条形图的视觉效果感到满意,请使用堆叠条形图(将其与一个元素的数组一起使用将像简单条形图一样绘制它)。那个将正确替换#x_label#。

或者,您可以将缺少的代码从 Bars/Stack.as 复制到其他条形类型并重新编译代码。

If you are happy with the simple bar visuals then use stacked bar (using it with an array of one element will draw it just like the simple bar). That one will replace #x_label# correctly.

Alternatively you can copy the missing code from Bars/Stack.as to other bar types and recompile the code.

何处潇湘 2024-09-15 18:50:30

As per: http://forums.openflashchart.com/viewtopic.php?p=7433#p7433
It's a bug in OFC2 in the latest versions (at least). I've found what is causing the issue with #x_label#, but my understanding of the code/Flash isn't good enough to know why it's happened/broken.
I've done a quick fix that I need to test some more, but it now works on bar charts. Assuming I've not broken anything else beyond repair, it'll make it's way into the next community release.
If anyone wants the source code changes before the next release let me know.

(I am currently maintaining the community releases)

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