弹性图表中 LegendItem 的自定义嵌入标记
我一直在使用 Flex 图表组件,我想在图例中嵌入标记的自定义图标。我遇到了一些奇怪的行为,如果直接设置,图标会镜像并且文本未对齐,但如果使用类工厂和 legendMarkerRenderer 属性创建,则组件渲染得很好。我在下面添加了一个片段来说明问题。
解决这个问题可能是可能的,但我很好奇是否有人对这里可能发生的情况有解释。
其他信息:Flex SDK 4.5.0.20967、FlashBuilder 4.5
这是以下代码片段的输出:
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:s="library://ns.adobe.com/flex/spark">
<fx:Script>
<![CDATA[
import mx.charts.LegendItem;
[Embed(source="/resources/GraphResetIcon.png")]
public static var icon:Class;
]]>
</fx:Script>
<s:layout>
<s:VerticalLayout/>
</s:layout>
<!-- This works fine -->
<mx:LegendItem legendMarkerRenderer="{new ClassFactory(icon)}" markerAspectRatio="1"
labelPlacement="right" label="Texty texty" markerHeight="11" markerWidth="11" />
<!-- This does not work -->
<mx:LegendItem marker="{new icon()}" markerAspectRatio="1" labelPlacement="right"
label="Texty texty" markerHeight="11" markerWidth="11" />
</s:Application>
I've been working with the flex charting component and I want to embed a custom icon for the marker in the legend. I've run into some strange behaviour where if set directly the icon is mirrored and the text is misaligned but if created using the a class factory and the legendMarkerRenderer property the component renders fine. I've included a snippet to illustrate the problem below.
Working around this problem may be possible but I'm curious if anyone has an explanation as to what could be going on here.
Additional info: Flex SDK 4.5.0.20967, FlashBuilder 4.5
This is the output of the below snippet:
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:s="library://ns.adobe.com/flex/spark">
<fx:Script>
<![CDATA[
import mx.charts.LegendItem;
[Embed(source="/resources/GraphResetIcon.png")]
public static var icon:Class;
]]>
</fx:Script>
<s:layout>
<s:VerticalLayout/>
</s:layout>
<!-- This works fine -->
<mx:LegendItem legendMarkerRenderer="{new ClassFactory(icon)}" markerAspectRatio="1"
labelPlacement="right" label="Texty texty" markerHeight="11" markerWidth="11" />
<!-- This does not work -->
<mx:LegendItem marker="{new icon()}" markerAspectRatio="1" labelPlacement="right"
label="Texty texty" markerHeight="11" markerWidth="11" />
</s:Application>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试
编辑:
我挖出了我的备份硬盘驱动器,这对我有用
原则上,这与您开始时几乎相同,但我将新创建的 Class 实例显式转换为 BitmapAsset。
Try
Edit:
I dug out my backup hard drive, and here is what works for me
In principle, this is almost the same as what you started out with, but I explicitly cast the newly created Class instance to BitmapAsset.