具有多个系列的 Flex 条形图标签功能?

发布于 2024-07-27 16:45:52 字数 760 浏览 9 评论 0原文

我有一个 Flex 条形图,其中包含两个集群格式的数据系列。 该系列称为“RequiredFunding”和“ApprovedFunding”,因此它们绘制在彼此旁边。 我遇到的问题是尝试格式化资金轴上的标签函数。 我显示了数千美元,需要使用美元符号和逗号进行格式化(我已经有此功能)。

当我尝试将标签函数应用于水平轴时,我返回 MoneyFormatter.format(labelValue),这是我的应用程序范围内的货币格式化程序,但这不起作用,因为 dataProvider 中有两种不同的金额...有 labelValue.RequiredFunding 和 labelValue.ApprovedFunding。

希望我正确地解释了这一点...有人有什么想法吗?

非常感谢,

-马特

编辑:我担心我没有解释得足够清楚! 不用担心。 基本上,我想将当前显示为 8000、16000、24000 和 32000 的底轴格式化为 $8,000、$16,000、$24,000 和 $32,000。 但问题是,该轴不会偏离所需资金金额或批准资金金额...它会自动适应较大的值...或者以某种方式将两个分组系列视为单独的系列...我是不确定。 例如,如果我将其设置为返回 MoneyFormatter.format(RequiredFunding),它将正确格式化...但它只会放置 requiredFunding 金额的标签(例如 $14,543、$2,543、$31,230),并且不会绘制任何条形图系列。 我希望这能解决问题。 如果有必要,我可以上传一些屏幕截图。

I have a Flex bar chart with two data series in a clustered format. The series are called RequiredFunding and ApprovedFunding, so they're plotted next to each other. The problem I am having is trying to format the label function on the Funding axis. I have several thousands of dollars being displayed and it needs to be formatted with dollar signs and commas (I have this functionality already).

When I try to apply a label function to the horizontal axis, I return MoneyFormatter.format(labelValue), which is my app-wide money formatter, but this doesn't work because there are two different money amounts in the dataProvider... there is labelValue.RequiredFunding and labelValue.ApprovedFunding.

Hopefully I explaned this correctly... does anyone have any ideas?

Much appreciated,

-Matt

EDIT: I was afraid I didn't explain this clearly enough! No worries. Basically, I want to format my bottom axis which currently says 8000, 16000, 24000, and 32000 to say $8,000, $16,000, $24,000, and $32,000. But the problem is, that axis isn't going off the RequiredFunding amount or the ApprovedFunding amount... it's automatically accomodating for whichever is the larger value... or somehow treating the two grouped series as individual series... I'm not certain. If I set it to return MoneyFormatter.format(RequiredFunding), for example, it will format it correctly... but it will only put the label for the RequiredFunding amounts (like $14,543, $2,543, $31,230) and won't plot either bar series. I hope this clears it up. If necessary I could upload some screen caps.

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

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

发布评论

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

评论(2

遥远的她 2024-08-03 16:45:52

我有这个并且它正在工作:

    <mx:CurrencyFormatter id="moneyFormatter" currencySymbol="$" thousandsSeparatorTo="," />
    <mx:BarChart dataProvider="{testData.Sample}">
        <mx:series>
            <mx:BarSeries yField="visitors"  />
            <mx:BarSeries yField="overhead" />
        </mx:series>
        <mx:horizontalAxis>
            <mx:CategoryAxis dataFunction="moneyFormat"/>
        </mx:horizontalAxis>
    </mx:BarChart>

moneyFormat 函数:

private function moneyFormat(cat:Object, labelItem:Object):String{
       return moneyFormatter.format(labelItem.value);
}

我使用了我自己的一些测试数据,所以不要介意奇怪的 yFields。 我希望这有帮助

I have this and it is working:

    <mx:CurrencyFormatter id="moneyFormatter" currencySymbol="$" thousandsSeparatorTo="," />
    <mx:BarChart dataProvider="{testData.Sample}">
        <mx:series>
            <mx:BarSeries yField="visitors"  />
            <mx:BarSeries yField="overhead" />
        </mx:series>
        <mx:horizontalAxis>
            <mx:CategoryAxis dataFunction="moneyFormat"/>
        </mx:horizontalAxis>
    </mx:BarChart>

moneyFormat function:

private function moneyFormat(cat:Object, labelItem:Object):String{
       return moneyFormatter.format(labelItem.value);
}

I used some test data that I had myself so don't mind the strange yFields. I hope this helps

二智少女猫性小仙女 2024-08-03 16:45:52

我不太确定你想要什么。 您可以在使用 labelValue.RequiredFunding 后调用 MoneyFormatter.format() ,然后在 labelValue.ApprovedFunding 后调用 MoneyFormatter.format() 吗? 可能是我没搞清楚

I'm not really sure what you want. You can just call the MoneyFormatter.format() after eachother with labelValue.RequiredFunding and after that labelValue.ApprovedFunding or not? Probably I don't get it right

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