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.72k stars 751 forks source link

x轴的y值指示线(动态高度)效果实现 #1383

Closed 54ZiLong closed 2 years ago

54ZiLong commented 2 years ago

截屏2022-09-01 下午9 15 52 请问这个指示线的效果能实现吗

AAChartModel commented 2 years ago

这个就只是网格线而已, 实现起来比较简单, 但是你的这个网格线高度不是规则的, 实现起来就比较复杂了.

54ZiLong commented 2 years ago

有没有示例可供参考呢

AAChartModel commented 2 years ago

配置示例:

- (AAOptions *)dynamicHeightGridLineAreaChart {
    return AAOptions.new
    .titleSet(AATitle.new
              .textSet(@"dynamicHeightGridLineAreaChart"))
    .chartSet(AAChart.new
        .typeSet(AAChartTypeScatter)
        .eventsSet(AAChartEvents.new
            .loadSet(@AAJSFunc(function () {
                const chart = this;
                const mainSeries = chart.series[0];
                mainSeries.data.forEach((point, i) => {
                  chart.addSeries({
                    data: [
                      [i, 0],
                      [i, point.y]
                    ]
                  })
                })
              }))))
    .plotOptionsSet(AAPlotOptions.new
        .scatterSet(AAScatter.new
            .lineWidthSet(@2)
            .lineColorSet(@"#dbe751")
            .dashStyleSet(AAChartLineDashStyleTypeLongDash)
            .enableMouseTrackingSet(@false)
            .linkedToSet(@"main")
            .statesSet(AAStates.new
                .inactiveSet(AAInactive.new
                    .enabledSet(false)))
            .markerSet(AAMarker.new
                .enabledSet(false))))
    .yAxisSet(AAYAxis.new
              .gridLineWidthSet(@0))
    .seriesSet(@[
        AASeriesElement.new
            .typeSet(AAChartTypeAreaspline)
            .idSet(@"main")
            .dataSet(@[@7.0, @6.9, @2.5, @14.5, @18.2, @21.5, @5.2, @26.5, @23.3, @45.3, @13.9, @9.6])
            .lineWidthSet(@6)
            .colorSet(@"#dbe751")
            .fillOpacitySet(@0.4)
            .markerSet(AAMarker.new
                .enabledSet(false))
    ]);
}

新增了部分属性及文件, 更新 AAChartKit 至最新内容即可使用.

AAChartModel commented 2 years ago

参考:

AAChartModel commented 2 years ago

参考:

54ZiLong commented 2 years ago
截屏2022-09-05 下午2 24 50

更新了最新版 但是报错,这是什么原因造成的

AAChartModel commented 2 years ago

参考:

AAChartModel commented 2 years ago

应该就是头文件导入的问题, 你改成导入 AAChartKit.h 应该就正常了.

AAChartModel commented 2 years ago
截屏2022-09-05 下午9 25 28

我本地测试, 导入 AAChartView.h 报错就是这样的, 与你的报错完全一致, 改为导入 AAChartKit.h 就正常了.