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

线在边界的时候被切了一半 #1414

Closed kedu closed 1 year ago

kedu commented 1 year ago

当边界是0,线也在0,被切了一半,变细了。希望不要被切

AAChartModel commented 1 year ago

参考:

kedu commented 1 year ago

设置max成0.1的时候,会崩溃,在 AAJsonConverter里的dictionaryWithObjectInstance的 id value = [objc valueForKey:propName];,麻烦看一下

kedu commented 1 year ago

能不能帮忙看一下

AAChartModel commented 1 year ago

这段 js 代码:

//Highcharts.chart("chart", {
//  chart: {
//    type: "line",
//    height: 300,
//  },
//  credits: {
//    enabled: false
//  },
//  legend: {
//    enabled: false
//  },
//  title: {
//    text: "Chart"
//  },
//  yAxis: [{
//    endOnTick: false,
//    max: 0.1,
//    title: {
//      text: "Negative values make me sad"
//    }
//  }],
//  series: [{
//    data: [0, 0, 0, -2, -2, -1, 0, -2], // If you put a `1` value in and then everything renders nicely.
//    lineWidth: 8
//  }]
//});

对应的 OC 代码为:

- (AAOptions *)toFixHighchartsWithAThickLineAt0ValuesTheLineIsHalfHidden {
    return AAOptions.new
    .chartSet(AAChart.new
              .typeSet(AAChartTypeLine)
              )
    .creditsSet(AACredits.new
                .enabledSet(false))
    .legendSet(AALegend.new
                .enabledSet(false))
    .titleSet(AATitle.new
                .textSet(@"Chart"))
    .yAxisSet((id)@[
        AAYAxis.new
        .endOnTickSet(false)
        .maxSet(@0.1)
        .titleSet(AAAxisTitle .new
                  .textSet(@"Negative values make me sad")),
    ])
    .seriesSet(@[
        AASeriesElement.new
        .dataSet(@[@0, @0, @0, @-2, @-2, @-1, @0, @-2])
        .lineWidthSet(@8),
    ]);
}
AAChartModel commented 1 year ago

更简洁的写法:

- (AAOptions *)toFixHighchartsWithAThickLineAt0ValuesTheLineIsHalfHidden {
    return AAOptions.new
    .chartSet(AAChart.new
              .typeSet(AAChartTypeLine))
    .creditsSet(AACredits.new
                .enabledSet(false))
    .legendSet(AALegend.new
               .enabledSet(false))
    .titleSet(AATitle.new
              .textSet(@"Chart"))
    .yAxisSet(AAYAxis.new
              .endOnTickSet(false)
              .maxSet(@0.1)
              .titleSet(AAAxisTitle .new
                        .textSet(@"Negative values make me sad")))
    .seriesSet(@[
        AASeriesElement.new
        .dataSet(@[@0, @0, @0, @-2, @-2, @-1, @0, @-2])
        .lineWidthSet(@8),
    ]);
}
AAChartModel commented 1 year ago

设置max成0.1的时候,会崩溃,在 AAJsonConverter里的dictionaryWithObjectInstance的 id value = [objc valueForKey:propName];,麻烦看一下

如果你的崩溃是由 yAxisSet 方法的参数类型不匹配引起的, 改为这个简洁的写法应该就可以了.