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

Color choices between line segments. #96

Closed
zugspitze opened this issue Nov 1, 2019 · 6 comments
Closed

Color choices between line segments. #96

zugspitze opened this issue Nov 1, 2019 · 6 comments
Labels
question Further information is requested

Comments

@zugspitze
Copy link

Thanks a lot for amazing package, I was wondering if it's possible to choose a color for different line segments. For example, if I have 4 points: A, B, C, D. I want to color the line between A-B in red, B-C in blue, C-D in green.

@imaNNeo
Copy link
Owner

imaNNeo commented Nov 1, 2019

Hi, pleasure,
You can have 4 different line chart with different colors.
Cheers!

@zugspitze
Copy link
Author

@imaNNeoFighT Thank you for quick reply :-)

I managed to use your trick to display different colors in line segments. Do you know how I can display only one tooltip instead of two for the points where line segments are touching. Please see the attached image.
Screen Shot 2019-11-01 at 12 10 05

@imaNNeo
Copy link
Owner

imaNNeo commented Nov 1, 2019

Use this code:

FlChart(
  chart: LineChart(
    LineChartData(
      .
      .
      .
      lineTouchData: LineTouchData(
        enabled: true,
        touchTooltipData: TouchTooltipData(
          getTooltipItems: (touchedSpots) {
            final tooltipItems = <TooltipItem>[];
            for (int i = 0; i < touchedSpots.length; i++) {
              if (i >= 1) {
                tooltipItems.add(null);
                continue;
              }
              final spot = touchedSpots[i];
              tooltipItems.add(TooltipItem(
                spot.spot.y.toString(),
                TextStyle(color: spot.getColor()),
              ));
            }
            return tooltipItems;
          }
        )
      ),
      .
      .
      .
    )
  ),
)

Inside the getTooltipItems you can return null to skip show the TooltipItem.

@imaNNeo imaNNeo added the question Further information is requested label Nov 1, 2019
@zugspitze
Copy link
Author

Thanks a lot @imaNNeoFighT for your reply, it works :-)

@biklas7
Copy link

biklas7 commented Feb 13, 2023

@imaNNeo sorry to awake this old issue, I didn't think I should open a new one just to ask this. How do you make the lines match when they are curved and have any smoothness?

@imaNNeo
Copy link
Owner

imaNNeo commented Feb 18, 2023

@imaNNeo sorry to awake this old issue, I didn't think I should open a new one just to ask this. How do you make the lines match when they are curved and have any smoothness?

Hi, No problem
Unfortunately, I think there is no way to do this with curved lines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants