'How To Display JSON Data in flutter Chart

I have tried to put JSON data in flutter chart, I used syncfusion_flutter_charts library but its not working and its only showing y axis point but not x axis points any one can help me the display json data in flutter SfCartesianChart Or help me in put this data in other charts of flutter

import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'dart:convert';
import 'package:syncfusion_flutter_charts/charts.dart';

class Graph extends StatefulWidget {
@override
_GraphState createState() => _GraphState();
}
class _GraphState extends State<Graph> {
Future<String> fetchUsers() async {
String url = 'http://example.com/json.php';
  var response = await http.get(url);
  print(response.body);
  return response.body.toString();
}

@override
  void initState() {
  loadSalesData();
  super.initState();
}

@override
Widget build(BuildContext context) {
    return Scaffold(
    appBar: AppBar(
      title: Text("Graph"),
    ),
    body: SfCartesianChart(
          title: ChartTitle(text: 'Leads'),
          primaryXAxis: CategoryAxis(),
          series: <LineSeries<LinearSales, String>>[
          LineSeries<LinearSales, String>(
            
            dataSource: chartData,
            xValueMapper: (LinearSales sales, _) => sales.name,
            yValueMapper: (LinearSales sales, _) => sales.leads,
          )
        ]));
      }

 List<LinearSales> chartData = [];
 Future loadSalesData() async {
  final jsonResponse = json.decode(jsonString);
 // print(jsonString);
 // print(jsonResponse);
 setState(() {
  for (Map i in jsonResponse) chartData.add(LinearSales.fromJson(i));
 });
 }
}
class LinearSales {
  LinearSales(this.name, this.leads);
  final String name;
  final int leads;
  factory LinearSales.fromJson(Map<String, dynamic> parsedJson) {
  //print(parsedJson);
  return LinearSales(
    parsedJson['name'],
    parsedJson['leads'],
  );
 }
}


Solution 1:[1]

I resolve this problem. refer int.parse()

class LinearSales {
  LinearSales(this.name, this.leads);
  final String name;
  final int leads;
  factory LinearSales.fromJson(Map<String, dynamic> parsedJson) {
  //print(parsedJson);
  return LinearSales(
    parsedJson['name'],
    int.parse(parsedJson['leads']),
  );
 }
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ravindra S. Patil