AAChartModel / AAChartKit

📈📊🚀🚀🚀An elegant modern declarative data visualization chart framework for iOS, iPadOS and macOS. Extremely powerful, supports line, spline, area, areaspline, column, bar, pie, scatter, angular gauges, arearange, areasplinerange, columnrange, bubble, box plot, error bars, funnel, waterfall and polar chart types. 极其精美而又强大的现代化声明式数据可视化图表框架,支持柱状图、条形图、折线图、曲线图、折线填充图、曲线填充图、气泡图、扇形图、环形图、散点图、雷达图、混合图等各种类型的多达几十种的信息图图表,完全满足工作所需.
https://cocoapods.org/pods/AAChartKit
MIT License
4.71k stars 750 forks source link

数据源数据都为0的时候:只显示为一个空白图 #1447

Closed mapleleaf99 closed 1 year ago

mapleleaf99 commented 1 year ago

作者你好, 当数据源数据都为0的时候: @[ @[@"AAAA", @(0)], @[@"BBBB", @(0)], @[@"CCCC", @(0)], @[@"DDDD", @(0)], @[@"EEEE", @(0)] ]; ,应该显示五等分吧 image

报错信息: image 有没有什么办法可以处理这种情况

AAChartModel commented 1 year ago

参考:

OC 版本的配置方式如下:

//https://github.com/AAChartModel/AAChartKit/issues/1042
- (AAOptions *)makePieChartShow0Data {
    return AAOptions.new
    .titleSet((id)NSNull.null)
    .chartSet(AAChart.new
              .typeSet(AAChartTypePie))
    .seriesSet(@[
        AASeriesElement.new
        .nameSet(@"ZeroDataPie")
        .dataSet(@[
            @{@"y":@1, @"isZero":@true, @"name": @"One"  },
            @{@"y":@1, @"isZero":@true, @"name": @"Two"  },
            @{@"y":@1, @"isZero":@true, @"name": @"Three"}
                 ])
        .tooltipSet(AATooltip.new
                    .sharedSet(false)
                    .pointFormatterSet(@AAJSFunc(
        function() {
            return "<span style=\'color:" + this.color + "\'> ◉ </span>"
            + this.series.name
            + ": <b>"
            + (this.options.isZero ? 0 : this.y)
            + "</b><br/>";
        })))
               ])
    ;
}

demo 中有此示例, 下载运行查看即可.

mapleleaf99 commented 1 year ago

好的我看看, 谢谢