Hyndrix
Hyndrix

Reputation: 4452

Hide primary axis in flutter chart

I have a primary axis defined as follows:

primaryMeasureAxis: new charts.NumericAxisSpec(
  tickProviderSpec: new charts.StaticNumericTickProviderSpec(
    <charts.TickSpec<num>>[
      charts.TickSpec<num>(_serverData.minVal),
      charts.TickSpec<num>(_serverData.maxVal),
    ],
  ),
),

How can I hide the axis while maintaining the TickSpec?

Regards,

Upvotes: 2

Views: 2994

Answers (2)

Epsi95
Epsi95

Reputation: 9047

for line chart this worked for me:

// hide x axis
  domainAxis: charts.NumericAxisSpec(
      showAxisLine: false, renderSpec: charts.NoneRenderSpec()),
  // hide y axis
  primaryMeasureAxis:
      charts.NumericAxisSpec(renderSpec: charts.NoneRenderSpec()),

more at: https://google.github.io/charts/flutter/example/axes/hidden_ticks_and_labels_axis.html

Upvotes: 2

Hyndrix
Hyndrix

Reputation: 4452

Got the solution:

renderSpec: new charts.NoneRenderSpec()

A full implementation for hiding the domain axis on a LineChart is here

charts.LineChart(chartData,
                defaultRenderer: new charts.LineRendererConfig(
                    includeArea: true, stacked: true),
                animate: false,
              domainAxis: new charts.NumericAxisSpec(
                  showAxisLine: true,
                  renderSpec: new charts.NoneRenderSpec()),),

Upvotes: 4

Related Questions