question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Prevent path going below axis minimum with spline/area-spline type

See original GitHub issue
  1. What version of C3? 0.4.10
  2. What browsers have you confirmed it in? All browsers.
  3. Can you isolate the issue by providing a jsFiddle demonstrating it in a minimalist capacity? https://jsfiddle.net/alanhamlett/qvgf8omq/

screen shot 2016-02-29 at 10 45 20 am

Notice how the line goes below the chart’s y-min. There should be an option to prevent this.

var chart = c3.generate({
  data: {
    type: 'spline',
    columns: [
      ['data1', 0, 0, 200],
      ['data2', 0, 0, 0]
    ],
    axis: {
      y: {
        min: 0
      }
    }
  }
});

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
tramckcommented, Mar 10, 2016

It’s a bit of a hack, since this doesn’t seem to be configurable on an invidiual chart basis, but you can override c3.chart.internal.fn.getInterpolate before initializing your chart to another interpolation method.

c3.chart.internal.fn.getInterpolate = () => 'monotone';

https://jsfiddle.net/qvgf8omq/3/

Edit: Even that doesn’t work in all cases https://jsfiddle.net/qvgf8omq/4/ . It seems to be a limitation of d3’s built-in interpolation methods, I’m sure there is a way to write your own interpolation method, but I don’t know d3 well enough to know how to do that.

2reactions
panthonycommented, Jul 26, 2019

In latest version of c3js you can pass:

{
   spline: {
     interpolation: {
        type: 'monotone'
     }
   }
}

Default values is cardinal, the possible values are:

            'linear': d3.curveLinear,
            'linear-closed': d3.curveLinearClosed,
            'basis': d3.curveBasis,
            'basis-open': d3.curveBasisOpen,
            'basis-closed': d3.curveBasisClosed,
            'bundle': d3.curveBundle,
            'cardinal': d3.curveCardinal,
            'cardinal-open': d3.curveCardinalOpen,
            'cardinal-closed': d3.curveCardinalClosed,
            'monotone': d3.curveMonotoneX,
            'step': d3.curveStep,
            'step-before': d3.curveStepBefore,
            'step-after': d3.curveStepAfter

I’m aware that this option is not yet documented 😕

Read more comments on GitHub >

github_iconTop Results From Across the Web

Change the scale of the horizontal (category) axis in a chart
To change the axis type to a text or date axis, expand Axis Options, and then under Axis Type, select Text axis or...
Read more >
How to move chart X axis below negative values/zero/bottom ...
Right click the X axis in the chart, and select the Format Axis from the right-clicking menu. 2. Go ahead based on your...
Read more >
GGPlot Axis Limits and Scales - Datanovia
This article describes R functions for changing ggplot axis limits (or scales). We'll describe how to specify the minimum and the maximum values...
Read more >
Change the Vertical Y Axis Start or End Point in Excel - YouTube
VBA/Macros Course (40% Discount): https://www.teachexcel.com/vba-course-update.php?src=youtube_v_description_r5RwETjFZNIExcel Quickie 36: ...
Read more >
Make Excel charts primary and secondary axis the same scale
So below we are showing the revenue (bill) and profit. ... The manual way to fix this is to go into the Axis...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found