如何在图表上显示叠加标签?
我有一个用 Birt 创建的图表,我想在上面添加一些标签来指定由 2 个红色标记分隔的 4 个区域(见下图),每个象限中有一个标签(如果可能的话居中)。
我正在寻找一个解决方案来做到这一点,直接使用 birt 图表编辑器或使用 javascript (就像我对红色标记所做的那样)。
I have a chart created with Birt and I want to add some label on it to specify the 4 regions delimited by the 2 red markers (see image below), one label in each quadrant (centered if possible).
I am looking for a solution to do that, directly using birt chart editor or by using a javascript (like I have done for the red markers).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了在图表的每个象限中动态地居中某种类型的标签,您必须有某种计算坐标的方法。 当然,我不太熟悉 Birt,我假设图表的红色标记会有所不同。
无论如何,假设您可以获得坐标,您可以编写一个函数,根据几个参数动态生成标签:
然后从那里,您可以使用设置的标签内容和偏移坐标调用此函数:
然后只需添加图形容器的元素(假设其
id
为graph
):In order to dynamically center some type of label in each quadrant of the graph, you'll have to have some way of calculating the coordinates. Of course, I'm not really familiar with Birt and I'm making the assumption that the graph's red markers will vary.
Anyway, assuming that you can get the coordinates, you could write a function that would dynamically generate the label based on a couple of parameters:
and then from there, you can call this function with the set label content and offset coordinates:
Then just add the element to the graph's container (assuming that is has an
id
of, say,graph
):