Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiline chart with common data point #1970

Closed
gsuneelji opened this issue Dec 16, 2016 · 4 comments
Closed

Multiline chart with common data point #1970

gsuneelji opened this issue Dec 16, 2016 · 4 comments

Comments

@gsuneelji
Copy link

gsuneelji commented Dec 16, 2016

How to distinguish a data point if two line datasets have a common data point.

This is what I expect
expected

This is what it is rendered
screen shot 2016-12-16 at 9 10 29 pm

`override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.

    months = ["M", "T", "W", "TH", "F", "S", "SU"]
    setChart(months)
}

func setChart(dataPoints: [String]) {
    lineChartView.noDataText = "You need to provide data for the chart."
    
    var dataEntries1: [ChartDataEntry] = []
    let values1 = [5.0, 4.0, 3.0, 4.0, 3.0, 1.0, 2.0]
    for i in 0..<dataPoints.count {
        let dataEntry = ChartDataEntry(value: values1[i], xIndex: i)
        dataEntries1.append(dataEntry)
    }
    let chartDataSet1 = LineChartDataSet(yVals: dataEntries1, label: "Units Sold")
    chartDataSet1.setColor(UIColor.blackColor())
    chartDataSet1.setCircleColor(UIColor.blackColor())
    
    
    var dataEntries2: [ChartDataEntry] = []
    let values2 = [4.0, 2.0, 3.0, 5.0, 2.0, 3.0, 1.0]
    for i in 0..<dataPoints.count {
        let dataEntry = ChartDataEntry(value: values2[i], xIndex: i)
        dataEntries2.append(dataEntry)
    }
    let chartDataSet2 = LineChartDataSet(yVals: dataEntries2, label: "Quantities Sold")
    chartDataSet2.setColor(UIColor.redColor())
    chartDataSet2.setCircleColor(UIColor.redColor())
    
    
    let chartData = LineChartData(xVals: months, dataSets: [chartDataSet1, chartDataSet2])
    lineChartView.data = chartData
    lineChartView.xAxis.labelPosition = .Bottom
}`
@KodiKraig
Copy link

Is this a question? I see a rendered pic with the only common data point circled.

@gsuneelji
Copy link
Author

Yeah. This is a question/requirement. The first pic is what I expect, to clearly distinguish both colors. But the graph that is rendered using Charts (second pic), the black circle is overridden by red circle. I want the chart to display both black & red colors clearly at a common data point as shown in the first pic

@KodiKraig
Copy link

KodiKraig commented Dec 18, 2016

Try adjusting these properties as you add the data sets:
data.circleRadius = CGFloat(5.0)
data.circleHoleRadius = CGFloat(2.0)
The only problem is that it will increase the size at all points which is not exactly what you want I think. To increase an individual one you'll have to do it custom considering the circleRadius is a property of the data set object.

@liuxuan30
Copy link
Member

liuxuan30 commented Dec 19, 2016

it's about orders for which render above which and make some changes about the circle or something. as @KodiKraig said, you have to use the radius for each data set to make it appear or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants