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

EmptyPointSettings modes are not working. #103

Closed
onurcanari opened this issue Apr 4, 2020 · 6 comments
Closed

EmptyPointSettings modes are not working. #103

onurcanari opened this issue Apr 4, 2020 · 6 comments

Comments

@onurcanari
Copy link

I am trying to remove empty points and I tried every mode. But nothing changes.

@dharanidharandharmasivam
Copy link
Contributor

Hi @onurcanari ,

Thanks for your interest in the Syncfusion Flutter Chart widget. We have analyzed your requirement and you can use the empty point mode as drop to achieve your scenario. To accomplish this requirement, we have prepared a sample and you can find the code snippet below.

  //Data source
  final List<ChartData> chartData = <ChartData>[
    ChartData('China', 12),
    ChartData('Brazil', null),
    ChartData('Bolivia', 8),
    ChartData('Mexico', null),
    ChartData('Egypt', 16),
    ChartData('Mongolia', 5),
 ];
//Code snippet for series
LineSeries<ChartData, String>(
      dataSource: chartData,
      emptyPointSettings:
          EmptyPointSettings(mode: EmptyPointMode.drop),
      //Other configuration
)

Screenshot:
Screenshot_20200406-152602

The sample for your reference can be found below.
https://www.syncfusion.com/downloads/support/directtrac/general/ze/emptyPoint-1717295653

For more information in empty points, find the user guide below.
https://help.syncfusion.com/flutter/chart/cartesian-series-customization#empty-points

Thanks,
Dharani.

@onurcanari
Copy link
Author

`
I am using financial series and this is not working.

    return CandleSeries<ChartData, DateTime>(
      enableSolidCandles: true,
      xValueMapper: (chartData, _) => chartData.date,
      animationDuration: 0,
      highValueMapper: (chartData, _) => chartData.high,
      lowValueMapper: (chartData, _) => chartData.last,
      openValueMapper: (chartData, _) => chartData.open,
      closeValueMapper: (chartData, _) => chartData.close,
      dataSource: chartModel.data,
      emptyPointSettings: EmptyPointSettings(mode: EmptyPointMode.drop),
      enableTooltip: true,
    );

`
image

With same settings

image

@dharanidharandharmasivam
Copy link
Contributor

Hi @onurcanari ,

Thanks for the information. We would like to let you know that the date-time axis is linearly plotting, for example, if you don’t have data for 28th March, then there will be space between 27th and 29th March. This is the default behavior of DateTime axis. This is the reason for the space occurrence in the date-time axis.

Thanks,
Dharani.

@onurcanari
Copy link
Author

Thank you. Is there a way to archive this?

@dharanidharandharmasivam
Copy link
Contributor

Hi @onurcanari ,

Yes, we can achieve this as a workaround using the category axis. We have prepared a sample which will meet your requirements.

Initially, you need to remove the null points from your data source and then render the chart with the new data source. And using the onAxislabelRender event, we can customize the axis labels. Find the code snippet to achieve this.

List<ChartSampleData> data = [];
// Removed the data if it is empty point
for (int i =0; i< chartData.length; i++){
  if(chartData[i].close != null && chartData[i].open != null && chartData[i].high != null && chartData[i].low != null){
    data.add(chartData[i]);
  }
}
 SfCartesianChart(
          primaryXAxis: CategoryAxis(
                  labelIntersectAction: AxisLabelIntersectAction.wrap
                ),
                  // Customized the x-axis  labels
                onAxisLabelRender: (AxisLabelRenderArgs args){
                  if(args.axisName == 'primaryXAxis'){
                    DateTime currentText = DateTime.parse(args.text);
                    args.text = DateFormat.MEd().format(currentText);
                  }
                },
            )

Our actual data source will be as below.

final List<ChartSampleData>  chartData = <ChartSampleData>[
    ChartSampleData(DateTime(2016, 01, 2), 98.97, 101.19, 95.36, 97.13),
    ChartSampleData(DateTime(2016, 01, 3), 98.41, 101.46, 93.42, 101.42),
    ChartSampleData(DateTime(2016, 01, 4), 101.52, 101.53, 92.39, 97.34),
    ChartSampleData(DateTime(2016, 01, 5),null,97.33, 93.69,94.02),
    ChartSampleData(DateTime(2016, 01, 6), 93.13,96.35,92.59,93.99),
];

Screenshot
Screenshot_20200408-191022

The sample for reference can be found below.
https://www.syncfusion.com/downloads/support/directtrac/general/ze/candle_category945675600

Thanks,
Dharani.

@onurcanari
Copy link
Author

Thank you again.

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

2 participants