如何访问字典或数组中的内容?

发布于 2024-11-24 08:18:39 字数 563 浏览 0 评论 0原文

在我的应用程序中,我有一些我无法处理的特殊场景。 我从 Xml 获取数据,并将其放入两个数组 Label 和 numProjects 中。 Label 包含标签,numProjects 包含各个标签的值。

有了这些值,我需要为每个标签绘制一个具有不同颜色的饼图。 我绘制图表的方式是将填充图表所需的数据放入一个数组中,并在另一个数组中放入不同部分所需的颜色。

所以这是代码的问题:

labelArray = [Active, pipeline, closed];
numProjectArray = [248, 438,200];// respective values as per the labelArray

现在在绘图时我需要这个 numProjectArray 并且我还需要创建另一个数组,其中包含我想要为各个部分着色的所有颜色。每个标签值颜色也应该有一个特定的对。对于每个标签,应该有一个存储在 numProjectArray 中的唯一值,对于这个标签值对,我们需要特定的颜色来绘制该部分。并且还需要在图表一侧显示此信息,其中颜色表示哪个标签。

请帮忙!!!

In my app i have some special scenario which i am not able to handle.
I am getting data from Xml which i am putting in two Arrays Label and numProjects.
Label contains labels and numProjects contains values for respective labels.

With these values i need to draw a pie chart with different colors for each label.
The way i am drawing the chart is i put the data with which i need to populate the chart in one array and in other array i put colors which i need for different sections.

So here's the problem with code:

labelArray = [Active, pipeline, closed];
numProjectArray = [248, 438,200];// respective values as per the labelArray

Now while drawing i need this numProjectArray and also i need to create another array which has all the colors i want to color the separate sections. Also there should be a specific pair for each of label-value-color. For each label there should be a unique value which is stored in numProjectArray and for this label-value pair we need a specific color to draw the section. And also need to display this information on side of graph that which color denotes which label.

Please help!!!

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

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

发布评论

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

评论(1

命比纸薄 2024-12-01 08:18:39

如果您问如何做得更好,您可能应该考虑类似字典数组的东西,每个标签/值/颜色一个字典。每个字典都有@“label”、@“numProjects”和@“color”等键以及相应的值。

If you're asking how to do this better, you should probably be thinking about something like an array of dictionaries, with one dictionary per label/value/color. Each dictionary would have keys like @"label", @"numProjects", and @"color", and corresponding values.

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