Skip to content

Questions about the usage of line charts #2034

@Big-Gremlin

Description

@Big-Gremlin

Hey,

after the mail conversation with Tanner and Evert, I will put the mails to this issue.

Today I tried ChartJS 2.0 (Beta 2 and current dev).

I want a time scaled line chart with dynamic data. That works fine, but the chart is not perfect.

chart

First Question
The xAxes has a min value of -150 and a max value of -50. ChartJS decides how many labels are will be shown.
What I need, is an option to set the maximum axis labels, like: "maxLabels: 5"
Or manually like "shownLabels: [-50, -75, -100, -125, -150]"

I need the same for the yAxes. In this case I want to restrict the time values in 4 or 5 labels.
The first point should define the start of the time scale and the last Point should finish the time scale.
I need to round the values to every 10 seconds, like in the picture (That was a coincidence. :) )

Second Question
How can I scale the radius of the point? I know how it works with the hover points.

Third Question
Is it possible to disable a dataset after initialization?

Final Question
AS you can see, the last data points are lower than -150. Is it possible to cut the rendered line at the bottom?

BTW: Bug?
The maxRotation was set to 0, but the labels are rotated.

Last but not least, my definition:

var data = {
   labels: [ new Date()
       ],
   datasets: [{
       label: "Signalstärke",
       fill: false,
       backgroundColor: "rgba(220,220,220,0.2)",
       borderColor: "#6ABCED",
       borderWidth: 1,
       pointBorderColor: "#0e4a80",
       pointBackgroundColor: "#fff",
       pointBorderWidth: 1,
       pointHoverRadius: 5,
       pointHoverBackgroundColor: "#fff",
       pointHoverBorderColor: "#0e4a80",
       pointHoverBorderWidth: 2,
       data: []
   }]
};

var options = {
   animation: false,
   responsive: true,
   maintainAspectRatio: false,
   tooltips: {
       enabled: false
   },
   scales: {
       yAxes: [{
           type: 'linear',
           ticks: {
               min: -150,
               max: -50
           }
       }],
       xAxes: [{
           type: 'time',
           ticks: {
               fontSize: 10,
               maxRotation: 0
           },
           time: {
               format: false,
               unit: false,
               displayFormats: {
                   'millisecond': 'HH:mm:ss',
                   'second': 'HH:mm:ss',
                   'minute': 'HH:mm:ss',
                   'hour': 'HH:mm:ss'
               },
               // Sets the display format used in tooltip generation
               tooltipFormat: ''
           },
           ticks: {
               maxTicksLimit: 11
           }
       }]
   }
};

var definition = {
   type: 'line',
   data: data,
   options: options
}; 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions