How to Create a Flutter Line Chart in 10 Minutes

Поделиться
HTML-код
  • Опубликовано: 12 июн 2024
  • Get an overview of the Syncfusion Flutter line chart. This video explains how to add the Syncfusion Flutter Charts package and a Cartesian chart to a Flutter project. It also explains how to set a data source to the chart and how to add a line series to it. You will also see how to customize the primary axis; add a title; and show data labels, legends, and tooltips in the line chart.
    [00:00] Introduction
    [01:12] Add a Cartesian chart to the app
    [02:35] Set data source and add line series
    [04:26] Customize the primary axis
    [05:30] Show data labels
    [05:56] Add a title
    [06:16] Show legend
    [06:46] Show tooltip in the chart
    Example project: bit.ly/3cvDlIu
    SYNCFUSION FLUTTER LINE CHART
    -----------------------------------------------------
    Product overview: bit.ly/2Pb6tMm
    Documentation: bit.ly/3cwKzfa
    API documentation: bit.ly/2Qw1JBa
    Examples-GitHub: bit.ly/3cG5f57
    Tutorial videos: bit.ly/3wdqvpV
    Demo-web: bit.ly/3caH7GO
    Demo-Android Play Store: bit.ly/3cAX75x
    Demo-Apple App Store: apple.co/2vP4aVa
    Download free trial: bit.ly/3u4gUzV
    Package in pub.dev: bit.ly/31rsBVc
    SUBSCRIBE
    ----------------
    Syncfusion on RUclips: bit.ly/syncfusionyoutube
    Sign up to receive email updates: bit.ly/syncfusionemail
    SOCIAL COMMUNITIES
    ---------------------------------
    Facebook: / syncfusion
    Twitter: / syncfusion
    LinkedIn: / syncfusion
    Hashtags:
    #fluttercharts #linechart #flutter
  • ХоббиХобби

Комментарии • 56

  • @fayezalle43
    @fayezalle43 2 года назад

    Thank you very much.. Very helpful!

    • @SyncfusionInc
      @SyncfusionInc  2 года назад

      Hi Ahmad,
      We are glad that you have found it helpful.

  • @fethisert5527
    @fethisert5527 Год назад

    Nice Video Thanks

  • @ashenNumberFour
    @ashenNumberFour 2 года назад

    I got it.
    Thank you so much!!!

    • @SyncfusionInc
      @SyncfusionInc  2 года назад

      Hi,
      We are glad that you have found it helpful.

  • @romulonavas5863
    @romulonavas5863 2 года назад

    Hi! Could you tell me please if it is possible with your library to create a line chart from a signal ? I mean, I get a stream of data and then the values will be showed in the chart every 200ms.

    • @SyncfusionInc
      @SyncfusionInc  2 года назад +1

      Hi Romulo,
      Thank you for watching our video and reaching out to us. Yes, it is similar to real-time data to chart. Here is a sample for you to depict this,
      flutter.syncfusion.com/#/cartesian-charts/real-time-charts/live-updates/real-time-spline-chart

  • @user-ej3gv4sc3e
    @user-ej3gv4sc3e Год назад

    Thank you for the good video. I'm drawing a graph of the data. I want to make it possible to look up the graph every hour, 6 hours, 12 hours, 24 hours. The value changes when printing, but the graph UI does not change. Can I ask for your help on this?

    • @SyncfusionInc
      @SyncfusionInc  Год назад

      Hi,
      We're happy to look at this. For the fastest response to technical questions, we recommend opening a support ticket so we can exchange files and screenshots.
      www.syncfusion.com/support/directtrac/incidents/newincident
      We will check on this with our team and post a response but it will take a little time.
      Thanks for your question!

    • @SyncfusionInc
      @SyncfusionInc  Год назад

      We suspect that you want to update the chart with real-time data for this. Please refer to this KB and demo sample to achieve your requirement.
      KB: www.syncfusion.com/kb/12316
      Sample: flutter.syncfusion.com/#/cartesian-charts/real-time-charts/live-updates/real-time-line-chart

  • @longnguyenduc5251
    @longnguyenduc5251 2 года назад

    hi , i am using StackedLineSeries to generate line chart , it is great , i want to ask how can i make the graph at initial render always scroll to the latest value ( max right ) , i am using visibleMaximum : 6 for primaryXAxis , now it always shows the oldest (max left) value, please help me, thank you very much.

    • @SyncfusionInc
      @SyncfusionInc  2 года назад

      Hi Long Nguyen Duc,
      We're happy to look at this. For the fastest response to technical questions, we recommend opening a support ticket so we can exchange files and screenshots.
      www.syncfusion.com/support/directtrac/incidents/newincident
      We will check on this with our team and post a response but it will take a little time.
      Thanks for your question!

    • @SyncfusionInc
      @SyncfusionInc  Год назад

      Please use the autoScrollingDelta and autoScrollingMode properties to show the last 6 data points in the chart. While setting the autoScrollingDelta value to 6, it always shows the last 6 values in the chart, eventhough if the chart gets updated.
      The autoScrollingMode used to set where you show that 6 data from starting or at the end. Kindly refer to the code snippet below to achieve your requirement.
      Code snippet:
      primaryXAxis: DateTimeAxis(
      autoScrollingDelta: 5,
      autoScrollingMode: AutoScrollingMode.start,
      )

  • @alanluong66
    @alanluong66 2 года назад

    Hi, is it possible to create x-axis longer than y-axis points? For example, for SalesData, I want the x-axis to show from year 2017-2025, but the sale only from 2017-2022.

    • @SyncfusionInc
      @SyncfusionInc  2 года назад +1

      Hi,
      Thank you for watching our video. You can achieve this by setting desired values to the maximum property in the axis. pub.dev/documentation/syncfusion_flutter_charts/latest/charts/NumericAxis/maximum.html
      SfCartesianChart(
      primaryXAxis: NumericAxis(maximum: 2022),
      )

    • @alanluong66
      @alanluong66 2 года назад

      @@SyncfusionInc Hi, would we be able to do this with SfSparkLineChart too?

    • @SyncfusionInc
      @SyncfusionInc  2 года назад

      Hi,
      SparkChart is a light-weight version of Charts. So it only have very minimal functionalities and this range maximum feature is not there in it. If you require this scenario, we request you to use SfCartesianCharts widget instead of SfSparkLineChart widget.
      Thanks for your question.

  • @ferryfarhanudin378
    @ferryfarhanudin378 2 года назад

    how to make two lines chart with neat data label settings?
    I have made it but the data label settings are irregular
    Thank you

    • @SyncfusionInc
      @SyncfusionInc  2 года назад

      Hi Ferry Farhanudin,
      We're happy to look at this. For the fastest response to technical questions, we recommend opening a support ticket so we can exchange files and screenshots.
      www.syncfusion.com/support/directtrac/incidents/newincident
      We will check on this with our team and post a response but it will take a little time.
      Thanks for your question!

    • @SyncfusionInc
      @SyncfusionInc  2 года назад

      Since we are not clear with the requirement, kindly share the below details to provide you with the solution earlier.
      1. Are you expecting the data labels to be positioned on the exact value as in the below image?
      2. Share some screenshots for the current behavior and expected behavior.
      Please find a sample for your reference below for positioning and alignment for the data label.
      flutter.syncfusion.com/#/cartesian-charts/series-features/data-label/default-data-labels

  • @satmal2834
    @satmal2834 3 года назад +1

    Hi, I amgetting following error
    Because no versions of syncfusion_flutter_charts match >18.4.49

    • @SyncfusionInc
      @SyncfusionInc  3 года назад

      Hello Sat,
      We can look into this and get back to you but response times via our RUclips videos are slower than our regular support. Have you opened a support ticket or tried our live chat? www.syncfusion.com/support/directtrac/incidents/newincident

    • @SyncfusionInc
      @SyncfusionInc  3 года назад

      Please use the latest version of the charts and make sure that you are not using the vector_math in your YAML file, since this package is used in our charts and so the version you are using may mismatch arise this issue.

    • @CnuFederer
      @CnuFederer 3 года назад

      instead of mentioning version number, use 'any' to get compatible plugin version.

  • @jacktherobot4210
    @jacktherobot4210 2 года назад

    Hello , I need help in something I need to display number of users in firebase per month using chart But I did not know how to count number of users in firebase can anyone help me with that

    • @SyncfusionInc
      @SyncfusionInc  2 года назад +1

      Hi Jack,
      Thank you for reaching out to us. Your requirement is not in our scope. You can check this with firebase forum. We only render the data sent to Chart from firebase.

  • @showmore5941
    @showmore5941 2 года назад

    I encounter this error "Expected a value of type 'num?', but got one of type 'String'" while my x axis is string and my y axis is double, can you help me, thanks

    • @SyncfusionInc
      @SyncfusionInc  2 года назад

      Hello,
      We can look into this and get back to you but response times via our RUclips videos are slower than our regular support. Have you opened a support ticket or tried our live chat? www.syncfusion.com/support/directtrac/incidents/newincident
      If you have a retail or flat license, you also have access to our support chat.

    • @SyncfusionInc
      @SyncfusionInc  2 года назад

      Please use the primaryXAxis as CategoryAxis if the x-axis values are string so that the exception will not occur.
      UG: help.syncfusion.com/flutter/cartesian-charts/axis-types#category-axis

  • @mohamedhassaan877
    @mohamedhassaan877 2 года назад

    how to make xValueMapper a DateTime data type not a double?

    • @SyncfusionInc
      @SyncfusionInc  2 года назад +1

      Hi Hassan,
      Thank you for reaching out and watching our video. Please find the demo for this scenario - flutter.syncfusion.com/#/cartesian-charts/axis-types/date-time/default-date-time-axis
      Code link of the above demo - github.com/syncfusion/flutter-examples/blob/master/lib/samples/chart/cartesian_charts/axis_types/date_time/default_date_time_axis.dart#L116
      Here, the dateTime values are assigned for xValueMapper to render DateTime axis.

    • @mohamedhassaan877
      @mohamedhassaan877 2 года назад

      @@SyncfusionInc thanks

    • @SyncfusionInc
      @SyncfusionInc  2 года назад

      Hi Hassan,
      We are glad it was helpful.

  • @unairobledillosanchez126
    @unairobledillosanchez126 11 месяцев назад

    Is possible to show more than one line in the same chart?

    • @SyncfusionInc
      @SyncfusionInc  11 месяцев назад

      Hello,
      Thank you for reaching out.
      In SfCartesianChart, we can render multiple series by adding the required series in the series collection property. Here, we have added a three-line series with different data points inside the series collection property.
      Kindly review the code snippet below:
      SfCartesianChart(
      primaryXAxis: NumericAxis(),
      primaryYAxis: NumericAxis(),
      series: >[
      LineSeries(
      dataSource: firstLine,
      xValueMapper: (ChartSampleData sales, int index) => sales.x,
      yValueMapper: (ChartSampleData sales, int index) => sales.y,
      color: Colors.blue,
      ),
      LineSeries(
      dataSource: secondLine,
      xValueMapper: (ChartSampleData sales, int index) => sales.x,
      yValueMapper: (ChartSampleData sales, int index) => sales.y,
      color: Colors.red,
      ),
      LineSeries(
      dataSource: thirdLine,
      xValueMapper: (ChartSampleData sales, int index) => sales.x,
      yValueMapper: (ChartSampleData sales, int index) => sales.y,
      color: Colors.green,
      ),
      ],
      ),

    • @SyncfusionInc
      @SyncfusionInc  11 месяцев назад

      Hello,
      We have analyzed your query and implemented the simple sample with the provided code snippet. As the data list is missing in the provided code snippet, assigned the data list with the dummy data points with three points each, and checked with your exact code. Two-line series with three data points, each is rendered properly with the attached sample below, and it is working fine from our end.
      If you face the issue further, we recommend you share the sample with data points in a runnable state, and it will be helpful to provide the best possible solution from our end.
      Kindy refer to the code snippet below:
      class _MyHomePageState extends State {
      late List> data;
      @override
      void initState() {
      data = >[
      [
      ChartData(x: '1', y: 40),
      ChartData(x: '2', y: 30),
      ChartData(x: '3', y: 100),
      ],
      [
      ChartData(x: '1', y: 10),
      ChartData(x: '2', y: 70),
      ChartData(x: '3', y: 20),
      ],
      ];
      super.initState();
      }
      @override
      Widget build(BuildContext context) {
      final List seriesList = [];
      for (final dataList in data) {
      final List chartDataList = _convertToChartData(dataList);
      final LineSeries series = LineSeries(
      dataSource: chartDataList,
      xValueMapper: (ChartData data, _) => data.x,
      yValueMapper: (ChartData data, _) => data.y,
      );
      seriesList.add(series);
      }
      return Scaffold(
      appBar: AppBar(
      title: const Text('Chart Data'),
      ),
      body: Padding(
      padding: const EdgeInsets.all(8.0),
      child: SfCartesianChart(
      series: seriesList,
      primaryXAxis: CategoryAxis(
      majorGridLines: const MajorGridLines(width: 0),
      ),
      primaryYAxis: NumericAxis(
      majorGridLines: const MajorGridLines(width: 0),
      ),
      ),
      ),
      );
      }
      List _convertToChartData(List dataList) {
      final List chartDataList = [];
      for (final item in dataList) {
      final String xValue = item.x;
      final double yValue = item.y;
      final ChartData chartData = ChartData(x: xValue, y: yValue);
      chartDataList.add(chartData);
      }
      return chartDataList;
      }
      }

  • @vitoman283
    @vitoman283 2 года назад

    does it cost anything if i use it in my app?

    • @SyncfusionInc
      @SyncfusionInc  2 года назад

      Hello Víctor Sánchez,
      Yes, you need to purchase the license to use it in your application. Our paid and free versions both have the same features and support. You can check here to see if you qualify for our Community (free) license. It's available for companies with 5 or fewer developers and less than $1 Mil USD in annual revenue.
      bit.ly/395t17c

  • @unwantedchild117
    @unwantedchild117 Год назад

    Hello! error: The argument type 'Null' can't be assigned to the parameter type 'Key' keep on showing on me

    • @SyncfusionInc
      @SyncfusionInc  Год назад

      Hi Unwanted Child,
      We're happy to look at this. For the fastest response to technical questions, we recommend opening a support ticket so we can exchange files and screenshots.
      www.syncfusion.com/support/directtrac/incidents/newincident
      We will check on this with our team and post a response but it will take a little time.
      Thanks for your question!

    • @SyncfusionInc
      @SyncfusionInc  Год назад

      Hi,
      We have created a sample based on the instructions in the RUclips video and have not been able to reproduce the issue on our end. Please provide more information on which scenario the exception gets thrown and what properties are enabled in the chart that will be more helpful to us assist you in a better way.

  • @RamanGoyal07
    @RamanGoyal07 3 года назад

    How to add icon in x axis in graph

    • @SyncfusionInc
      @SyncfusionInc  3 года назад

      Hi RMN, we can look into this and get back to you but response times via our RUclips videos are slower than our regular support. Have you opened a support ticket or tried our live chat? www.syncfusion.com/support/directtrac/incidents/newincident

    • @SyncfusionInc
      @SyncfusionInc  3 года назад

      Hello RMN,
      You should be able to add a marker using the documentation page for our cartesian chart: help.syncfusion.com/flutter/cartesian-charts/marker-datalabel.
      Please let us know if you have further questions. If you've tried this and it didn't work, you can also open a support ticket for a faster response.

  • @MatteoToma
    @MatteoToma 2 года назад

    how to show every value on the chart?

    • @SyncfusionInc
      @SyncfusionInc  2 года назад

      Hello Matteo,
      Thank you for reaching out. Simply, you can bind the data source to the chart. By default, all the data in the data source will be displayed in the chart.

  • @sageat1242
    @sageat1242 Год назад

    How can we display percentage instead of dollar?

    • @SyncfusionInc
      @SyncfusionInc  Год назад

      Hi SAGE AT,
      We're happy to look at this. For the fastest response to technical questions, we recommend opening a support ticket so we can exchange files and screenshots.
      www.syncfusion.com/support/directtrac/incidents/newincident
      We will check on this with our team and post a response but it will take a little time.
      Thanks for your question!

    • @SyncfusionInc
      @SyncfusionInc  Год назад

      You can customize the axis labels of the chart using the labelFormat (pub.dev/documentation/syncfusion_flutter_charts/latest/charts/NumericAxis/labelFormat.html) property available in the chart axis.
      Code Snippet :
      SfCartesianChart(
      primaryYAxis: NumericAxis(
      // '%' will be append to all the labels in Y axis
      labelFormat: '{value}%'
      )
      )
      Please refer to this documentation for the labelFormat property.
      help.syncfusion.com/flutter/cartesian-charts/axis-customization#formatting-axis-label-content

  • @fethisert5527
    @fethisert5527 Год назад

    Why we InitState to initialize chartData

    • @fethisert5527
      @fethisert5527 Год назад

      Why we use*

    • @SyncfusionInc
      @SyncfusionInc  Год назад

      Hello,
      We can look into this and get back to you but response times via our RUclips videos are slower than our regular support. Have you opened a support ticket or tried our live chat? www.syncfusion.com/support/directtrac/incidents/newincident
      If you have a retail or flat license, you also have access to our support chat.

    • @SyncfusionInc
      @SyncfusionInc  Год назад

      We would like to let you know that the 'initState' method will be called only once when the Stateful Widget is inserted into the widget tree. This method is typically used for some sort of initialization work that must be completed before the 'build'. Whereas the 'build' method will be called in many situations, such as state changes or parent rebuild cases, we must avoid initialization work in the build method.
      We kept the chart data static in the webinar video, so we preferred 'initState,' and we recommend that you initialize your chart data before the build to get the best performance.

    • @fethisert5527
      @fethisert5527 Год назад

      @@SyncfusionInc Thank you