charts icon indicating copy to clipboard operation
charts copied to clipboard

Y axis: define low and high point of data

Open electricalessence opened this issue 7 years ago β€’ 8 comments

Hello guys! I hope you're all well, I have an issue with the line chart. Is there a way to define the Y axis lower value to 0, even thought the values entered are all in "100"?And is there a way to define the Y axis higher value to 100 aswell? How can I do that?

by the way, thank you for making this library, I love it! Is there more documentation?

Thanks in advance, Myr * g4

the datasets

    datasets: [
      {
        title: "Finiquito", color: "green",
        values: [100, 100, 100, 100, 100, 100]
      }
    ]

Here comes the whole code:



	  let linedatatest = {
	    labels: ["May", "Jun", "Jul", "Aug", "Sep", "Oct"],

	    datasets: [
	      {
	        title: "Finiquito", color: "green",
	        values: [0, 100, 100, 100, 100, 100]
	      }
	    ]
	    
	  };

	  let linecharttest = new Chart({
	    parent: "#linedatatest", // or a DOM element
	    title: "Linedata",
	    data: linedatatest,
	    type: 'line', // or 'line', 'scatter', 'pie', 'percentage'
	    width: 720,
	    height: 230,
	    format_tooltip_x: d => (d + '').toUpperCase(),
	    format_tooltip_y: d => d + ' pts'
	  });

FrappΓ© Charts version: https://unpkg.com/[email protected]/dist/frappe-charts.min.iife.js

electricalessence avatar Nov 29 '17 13:11 electricalessence

I would love to know too. Can't find any documentation on this.

rojakcoder avatar Mar 23 '18 05:03 rojakcoder

My workaround is to put an empty y-marker.

let linedatatest = {
    labels: ["May", "Jun", "Jul", "Aug", "Sep", "Oct"],
    datasets: [
        {
            title: "Finiquito", color: "green",
            values: [0, 100, 100, 100, 100, 100]
        }
    ],
    yMarkers: [
        {
            label: '',
            value: 0,
            type: 'solid'
        }
    ]
};

It works for me.

rojakcoder avatar Mar 23 '18 06:03 rojakcoder

Being able to set the minimum, maximum and increment values for the Y axis would be very helpful. I think it would help solve this issue as well as #100 and #127.

kepano avatar Apr 22 '18 01:04 kepano

This is definitively a needed feature. Is this something that will be implemented in the future?

filipegeric avatar Apr 11 '20 11:04 filipegeric

Hey if there is any guidance on how someone might approach this I might take a crack at it at some point πŸ‘ I just ran across this issue myself where I don't want to have any increment less that a whole number (and also I want the minimum to always be at 0)

mansona avatar Dec 15 '20 22:12 mansona

I think #264 can be closed as a duplicate of this issue.

@mansona Did you try the workaround in https://github.com/frappe/charts/issues/86#issuecomment-375557382?

mathiasbynens avatar Jan 12 '21 15:01 mathiasbynens

so It's been so long for me that I'm not sure which issue is referring to what any more πŸ™ˆ @mathiasbynens I looked at my code and it does seem to make sure that all graphs have a 0 in them if that's what you're hoping the workaround does

In my case I would love a way to properly influence the Y axis and make it not show 0.25 entries when my graph has a high number of 1 😞

mansona avatar Jan 26 '23 16:01 mansona

In fact I just solved my problem with an even worse workaround πŸ™ˆ I now have 2 yMarkers:

yMarkers: [
        {
            label: '',
            value: 0,
            type: 'solid'
        },
        {
          label: '',
          value: 5,
          type: 'solid'
        }
    ]

and that will prevent partial numbers from showing in the graph. And since I really don't have a need for numbers I'm just ignoring them always with CSS:


.frappe-chart .y-markers {
  display: none;
}

It's not a great solution, and you can't use it if you ever want to actually use markers but 🀷

mansona avatar Jan 26 '23 16:01 mansona