score:1
see http://www.chartjs.org/docs/latest/axes/cartesian/time.html for setting time scale on xaxes, then you have to convert your date field to a real date object:
xaxes: [{
type: 'time',
distribution: 'linear',
ticks: {
source: 'labels'
},
time: {
unit: 'month',
unitstepsize: 1,
displayformats: {
'month': 'mmm'
}
}
}
check this jsfiddle showing an example of time serie rendered as a line: https://jsfiddle.net/beaver71/9f9a2z88/
score:0
you have 2 separate your data array into 2 different arrays. one of dates (say dates_array) and another of price (say price_array). then you just have to create new chart.
var chart = new chart(element, {
type: 'line',
data: {
labels: dates_array,
datasets: [{
label: '# price',
data: price_array
}]
}
});
here, element is the element in which chart will be shown. labels
will be assigned the date array and data
will be assigned price array. you can check this jsfiddle https://jsfiddle.net/j7gta8yn/
Source: stackoverflow.com
Related Query
- Price history with chart js
- what is wrong with my code ? java script chart position
- How can I create a horizontal scrolling Chart.js line chart with a locked y axis?
- Chartjs random colors for each part of pie chart with data dynamically from database
- ChartJS New Lines '\n' in X axis Labels or Displaying More Information Around Chart or Tooltip with ChartJS V2
- How to prevent first/last bars from being cut off in a chart with time scale
- ChartJS - Draw chart with label by month, data by day
- Horizontal stacked bar chart with chart.js
- line chart with {x, y} point data displays only 2 values
- Vertical stacked bar chart with chart.js
- Display line chart with connected dots using chartJS
- Chartjs 2 - Stacked bar and unstacked line on same chart with same y axis
- Chart.js - line chart with two yAxis: "TypeError: yScale is undefined"
- How to fix chart Legends width-height with overflow scroll in ChartJS
- How to display Line Chart dataset point labels with Chart.js?
- chart js how to fill legend box with colour
- Chart.js Mixed Bar and Line chart with different scales
- chart.js Line chart with different background colors for each section
- How do I draw a vertical line on a horizontal bar chart with ChartJS?
- reactive chart with chart.js in meteor
- chartjs: How to plot multi-line chart with irregular intervals
- Problem for display a chart with Chart.js and Angular
- How to display inline values in a stacked bar chart with Chart.js?
- Chart.js - Draw bar chart with multiple labels
- Show X axis on top and bottom in line chart rendered with Chart.js 2.4.0
- ChartJS bar chart with legend which corresponds to each bar
- Chart.js Dynamically Updating Chart with X Axis Time
- Chart.js: Line chart with partial dashed line
- Obtain max value of y axis of line chart rendered with Chart.js
- ChartJS - Line Chart with different size datasets
More Query from same tag
- Accesing external Javascript (Chart.js) with Thymeleaf
- How to add a custom event on legend click
- Is There any way to show image on top of the stacked bar, Am getting image on every color Instead of that i need only on top of each bar
- Problem with script src for Chart.js. The CDN for Chart.js funtions fine, so my code is ok. Somehow I'm not linking the file correctly
- I´m unable to map elements of an array
- Rails and Chart.js
- ChartJS and Flask, how to pass data?
- How do I change the label and value like 500,000 to 500k in Chart.js?
- ChartJS + twig symfony
- How can I change the color of certain lines in chartjs / vue-chartjs?
- How to generate PDF with Chart.js
- Chart.js dataset options externally with functionality
- Chart.js error Cannot read property 'length' of null
- How to fill my chart (chart.js) with my own data from API
- How do I customize the chart.js tooltip? Two labels have the same data, which I want to show you with each data
- Chart.js how to inser values from json
- Line graph in Angular 7 not working - is data type proper?
- Labeling and Data (ChartJS)
- Ionic: Doughnut Chart's legend occupies complete card in mobile, while on big screen chart and legend looks fine
- how to change size of point in ChartJS
- Understanding Chart.js and Adding Legends to Pie Charts
- How to stop displaying the data values from different data objects on Chart JS 2.x?
- Use JSON data in Chart.js chart
- Chart.js - Line chart does not render all points when using Point[] format
- How to get item what been clicked on Chart (primeNg chart + angular application)
- Setting max, min and stepSize values in a Chart.js graph
- javascript : extrapolate an array of numbers
- How to set min max for x axis depend on data with Chartjs and Spring Boot?
- Chart.js radar chart ticks are hidden behind the graph
- How to align vertical axis area on two charts in chart.js