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

select the first line by default #54

Closed
Cyycl opened this issue Nov 6, 2019 · 3 comments
Closed

select the first line by default #54

Cyycl opened this issue Nov 6, 2019 · 3 comments

Comments

@Cyycl
Copy link

Cyycl commented Nov 6, 2019

There are multiple lines, I want to select the first line by default, how can I do it?

Thanks~~

@dharanidharandharmasivam
Copy link
Contributor

Hi @Cyycl ,

Thanks for using our Syncfusion Flutter chart widget. Your requirement for selecting the line can be achieved using initialSelectedDataIndexes of series property. Here you need to pass the point index value to select the segment. You can find the code snippet below in which we have passed all the point index value using a loop since your requirement is to select the first series. You can change this based on your requirements.

 SfCartesianChart(
    series: <CartesianSeries>[

        LineSeries<ChartData, String>(
          
            // Specify the point index value
            initialSelectedDataIndexes: dataSelection,

            selectionSettings: SelectionSettings(
              enable: true,
              selectedColor: Colors.red,
              selectedBorderWidth: 4
            )),

        LineSeries<ChartData, String>(
            //...
        ),

        LineSeries<ChartData, String>(
            //...
        ),
      ],
    )

For your convenience, we have attached the sample.

Hope this helps.

Thanks,
Dharani.

@Cyycl
Copy link
Author

Cyycl commented Nov 6, 2019

thanks, @dharanidharandharmasivam.

Thank you very much for the example, but the example display is not what I want.

I want to show the selected line by default, and the rest don't show.
As show below,MB is selected by default,MM and BB are not selected,so MB is only showed.

@dharanidharandharmasivam
Copy link
Contributor

Hi @Cyycl ,

Thanks for your information. You can hide the series using the isVisible property. By default, the isVisible property of the series will be true, if you set this to false then the series will be hidden. Find the sample and code snippet below to achieve this.

 SfCartesianChart(
      series: <CartesianSeries>[
        LineSeries<ChartData, String>(
            name: 'MB'),
        LineSeries<ChartData, String>(
            isVisible: false,
            name: 'MM'),
        LineSeries<ChartData, String>(
            isVisible: false,
            name: 'BB')
      ],
    )

Thanks,
Dharani.

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