【问题标题】:How to interchange colors of the bar graphs dynamically using coreplot如何使用 coreplot 动态交换条形图的颜色
【发布时间】:2014-02-13 07:56:04
【问题描述】:

我尝试实现下面提到的链接中提供的堆叠条。

每次我运行这个示例应用程序时,绘图的最大值总是用红色表示。这是我得到的日志。

2014-02-13 13:04:18.347 CorePlotBarChartExample[3666:70b] {
"2012-05-01" =     {
    "Plot 1" = 7;
    "Plot 2" = 7;
};
"2012-05-02" =     {
    "Plot 1" = 5;
    "Plot 2" = 6;
};
"2012-05-03" =     {
    "Plot 1" = 7;
    "Plot 2" = 9;
};
**"2012-05-04"** =     {
    **"Plot 1" = 10;**
    **"Plot 2" = 4;**
};
**"2012-05-05" =     {
    "Plot 1" = 4;
    "Plot 2" = 10;**
};
"2012-05-06" =     {
    "Plot 1" = 6;
    "Plot 2" = 1;
};
"2012-05-07" =     {
    "Plot 1" = 8;
    "Plot 2" = 6;
};

}

对于日期 2012-05-04,绘图 1 的值为 10,由红色表示。 对于日期 2012-05-05,情节 2 的值为 10,这也是红色。[我期待蓝色]

我想交换颜色,即 对于日期 2012-05-04 Plot 1 的值是 10。我应该给红色。 对于日期 2012-05-05 Plot 2 的值为 10。我应该给出蓝色。

这是在模拟器中运行的图像的链接:
链接:http://i.stack.imgur.com/AhQaB.png

堆叠条示例的链接:https://github.com/gilthonweapps/CorePlotBarChartExample

还有人可以为我提供最好的链接/教程,用于使用核心图的堆叠条吗?

【问题讨论】:

    标签: iphone objective-c ios7 core-plot


    【解决方案1】:

    你需要使用委托方法:

    -(CPTFill *)barFillForBarPlot:(CPTBarPlot *)barPlot recordIndex:(NSUInteger)index;
    

    它为您提供了一个条形图和索引,因此您可以使用它来查找数据源中的数据,如果它符合您的标准,您可以设置正确的颜色。

    【讨论】:

      【解决方案2】:

      确保每个地块都有一个唯一的identifier。在数据源中检查它并确保您返回正确绘图的值。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-05-13
        • 1970-01-01
        • 1970-01-01
        • 2016-10-24
        • 2018-08-22
        • 2020-03-22
        • 2023-03-23
        • 1970-01-01
        相关资源
        最近更新 更多