AnyChart / AnyChart-iOS

Other
80 stars 8 forks source link

Quadrant Chart data entry #2

Closed Halimeh-manaf closed 5 years ago

Halimeh-manaf commented 5 years ago

I'm trying to use the Quadrant Chart and unfortunately, there is no documentation for this graph in the docs. I have searched over and over and nothing is related to swift. The labels are displayed correctly but with no value. I would appreciate any hints.

    `let chart = AnyChart.quadrant()
    let data: Array<DataEntry> = [
        CustomDataEntry(x: "1", value: 2, value2: 3),
        CustomDataEntry(x: "2", value: 8, value2: 7),
        CustomDataEntry(x: "3", value: 5, value2: 9),
        CustomDataEntry(x: "4", value: 10, value2: 1),
    ]
    chart.xAxis(index: 3)
    chart.yAxis(index: 3)
    chart.line(data: data).name(name: "WHAT")
    chart.marker(data: data).name(name: "LOL")
    chart.labels().enabled(enabled: true)
    chart.quarters(settings: "{\n" +
        "      rightTop: {\n" +
        "        title: {\n" +
        "          text: '1',\n" +
        "          fontColor: '#ff8f00',\n" +
        "          padding: 10\n" +
        "        }\n" +
        "      },\n" +
        "      rightBottom: {\n" +
        "        title: {\n" +
        "          text: '2',\n" +
        "          fontColor: '#ff8f00',\n" +
        "          padding: 10\n" +
        "        }\n" +
        "      },\n" +
        "      leftTop: {\n" +
        "        title: {\n" +
        "          text: '3',\n" +
        "          fontColor: '#ff8f00',\n" +
        "          padding: 10\n" +
        "        }\n" +
        "      },\n" +
        "      leftBottom: {\n" +
        "        title: {\n" +
        "          text: '4',\n" +
        "          fontColor: '#ff8f00',\n" +
        "          padding: 10\n" +
        "        }\n" +
        "      }\n" +
        "    }")

    chart.title(settings: "Global")

    anyChartView.setChart(chart: chart)
}

class CustomDataEntry: ValueDataEntry {
    init(x: String, value: Double, value2: Double) {
        super.init(x: x, value: value)
        setValue(key: "value", value: value)
        setValue(key: "value2", value: value2)
    }`
Halimeh-manaf commented 5 years ago

OK just for the future reference, if one faced this problem, this is how I solved it: This is how the data entry should look like (still not sure about the label thou): class CustomDataEntry: BubbleDataEntry { init(x: Double, y: Double, size: Double , label: String) { super.init(x: x, value: y, size: size) setValue(key: "label", value: label) } }

Add your data. Then,

chart.marker(data: data).name(name: "Your Comment")