php折线图(line chart),swift-linechart - 功能完整、实用的iOS折线图组件

Swift LineChart

6576d090d8c550b75872a11f927d02ad.gif

Usage

var lineChart = LineChart()

lineChart.addLine([3, 4, 9, 11, 13, 15])

Features

Super simple

Highly customizable

Auto scaling

Touch enabled

Area below lines

Properties

Both x and y properties are of type Coordinate. Each can be customized separately and has its own settings for labels, gridlines and axis.

labels: Labels

grid: Grid

axis: Axis

Labels can be switched on and off and they can have custom values.

visible: Bool = true

values: [String] = []

Grid can also be switched on/off, has a custom color and you can specify how many gridlines you'd like to show.

visible: Bool = true

count: CGFloat = 10

color: UIColor = UIColor(red: 238/255.0, green: 238/255.0, blue: 238/255.0, alpha: 1) // #eeeeee

Axis can be switched on/off, has a property to its color and you can specify how much the axis is inset from the border of your UIView.

visible: Bool = true

color: UIColor = UIColor(red: 96/255.0, green: 125/255.0, blue: 139/255.0, alpha: 1) // 607d8b

inset: CGFloat = 15

Animations can be customized through the Animation settings.

enabled: Bool = true

duration: CFTimeInterval = 1

If you'd like to show extra dots at your data points use the Dots features.

visible: Bool = true

color: UIColor = UIColor.whiteColor()

innerRadius: CGFloat = 8

outerRadius: CGFloat = 12

innerRadiusHighlighted: CGFloat = 8

outerRadiusHighlighted: CGFloat = 12

In addition to the above mentioned features you can further customize your chart.

area: Bool = true - Fill the area between line and x axis

lineWidth: CGFloat = 2 - Set the line width

colors: [UIColor] = [...] - Colors for your line charts

Methods

Add line to chart.

lineChart.addLine(data: [CGFloat])

Remove charts, areas and labels but keep axis and grid.

lineChart.clear()

Make whole UIView white again

lineChart.clearAll()

Delegates

didSelectDataPoint()

Touch event happened at or close to data point.

func didSelectDataPoint(x: CGFloat, yValues: [CGFloat]) {

println("\(x) and \(yValues)")

}

Examples

Single line with default settings.

d3358f1d856af7bfc7bd290acb9cafb2.png

var lineChart = LineChart()

lineChart.addLine([3, 4, 9, 11, 13, 15])

Two lines without grid and dots.

cf0142d529f9d71701f47b85969cd4ce.png

var lineChart = LineChart()

lineChart.area = false

lineChart.x.grid.visible = false

lineChart.x.labels.visible = false

lineChart.y.grid.visible = false

lineChart.y.labels.visible = false

lineChart.dots.visible = false

lineChart.addLine([3, 4, 9, 11, 13, 15])

lineChart.addLine([5, 4, 3, 6, 6, 7])

Show x and y axis

456146cf885c6c9fd0bda5ac578485a3.png

var lineChart = LineChart()

lineChart.area = false

lineChart.x.grid.count = 5

lineChart.y.grid.count = 5

lineChart.addLine([3, 4, 9, 11, 13, 15])

lineChart.addLine([5, 4, 3, 6, 6, 7])

License

MIT

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
数据可视化堆积折线图是一种常用的数据可视化方式,可以用来展示多个数据系列在不同时间或者其他维度上的变化趋势,并且可以将这些数据系列叠加在一起展示。 在HBuilder中,你可以使用一些常见的数据可视化库来实现堆积折线图的绘制,比如ECharts、Highcharts等。这些库提供了丰富的配置选项和API,可以帮助你灵活地定制和展示堆积折线图。 以下是使用ECharts库在HBuilder中绘制堆积折线图的简单示例: 1. 引入ECharts库: ```html <script src="https://cdn.jsdelivr.net/npm/echarts@5.2.2/dist/echarts.min.js"></script> ``` 2. 创建一个具有一定宽高的DOM容器: ```html <div id="chart" style="width: 600px; height: 400px;"></div> ``` 3. 编写JavaScript代码,配置和绘制堆积折线图: ```javascript // 初始化echarts实例 var myChart = echarts.init(document.getElementById('chart')); // 配置项 var option = { title: { text: '堆积折线图示例' }, tooltip: { trigger: 'axis' }, legend: { data: ['数据系列1', '数据系列2', '数据系列3'] }, xAxis: { type: 'category', data: ['一月', '二月', '三月', '四月', '五月', '六月'] }, yAxis: { type: 'value' }, series: [ { name: '数据系列1', type: 'line', stack: '总量', data: [120, 132, 101, 134, 90, 230] }, { name: '数据系列2', type: 'line', stack: '总量', data: [220, 182, 191, 234, 290, 330] }, { name: '数据系列3', type: 'line', stack: '总量', data: [150, 232, 201, 154, 190, 330] } ] }; // 使用配置项绘制图表 myChart.setOption(option); ``` 这样就可以在HBuilder中绘制一个简单的堆积折线图了。你可以根据自己的需求,调整配置项和数据,来实现更加丰富和复杂的堆积折线图效果。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值