score:8
Edit: I edited the post to show horizontal lines of an empty graph as @zazu asked for it
In this sample, I set up a Chart.js line graph, providing a first dataset with data (in order to scale the grid vertical axis and make the horizontal lines visible), and a second one with empty data. This results in an empty graph, but with the full grid visible:
var data = {
labels: ["January", "February", "March", "April", "May", "June", "July"],
datasets: [
// invisible dataset
{
label: "",
fillColor: "rgba(220,220,220,0.0)",
strokeColor: "rgba(220,220,220,0)",
pointColor: "rgba(220,220,220,0)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(220,220,220,1)",
// change this data values according to the vertical scale
// you are looking for
data: [65, 59, 80, 81, 56, 55, 40]
},
// your real chart here
{
label: "My dataset",
fillColor: "rgba(220,220,220,0.2)",
strokeColor: "rgba(220,220,220,1)",
pointColor: "rgba(220,220,220,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(220,220,220,1)",
data: []
}
]
};
var options = {
animation: false,
///Boolean - Whether grid lines are shown across the chart
scaleShowGridLines : true,
//Boolean - Whether to show vertical lines (except Y axis)
scaleShowVerticalLines: true,
showTooltips: false
};
var ctx = document.getElementById("myChart").getContext("2d");
var myLineChart = new Chart(ctx).Line(data, options);
<script src="http://www.chartjs.org/assets/Chart.js"></script>
<canvas id="myChart" width="400" height="400"></canvas>
JSFiddle here.
Source: stackoverflow.com
Related Query
- Chart js display empty plot
- Chart.js pie chart to display "No Data" if the datasets are empty
- Display ellipsis for null or empty values in the bar chart using Chart.js
- Display line chart with connected dots using chartJS
- How to display Line Chart dataset point labels with Chart.js?
- chartjs: How to plot multi-line chart with irregular intervals
- Hide empty bars in Grouped Stacked Bar Chart - chart.js
- Display values outside of pie chart in chartjs
- How to display value of only one datapoint in line chart
- Problem for display a chart with Chart.js and Angular
- How to display inline values in a stacked bar chart with Chart.js?
- Display a limited number of labels only on X-Axis of Line Chart using Chart.js
- Display Doughnut Pie Chart As Circle Progress Chart.js
- How to display data labels outside in pie chart with lines in ionic
- How to display the labels in doughnut chart using ng2 charts?
- ChartJs line chart - display permanent icon above some data points with text on hover
- How can I display the xAxes and yAxes data in the tooltip, Chart JS?
- Mixed chart scatter plot with chart.js
- Chart JS display Data Value on the top of the Bar
- Display Date Label in axes - chart js/ng2 charts
- ChartJS - how to display line chart with single element as a line? (not as a dot)
- Display labels on bar chart using Chart.js
- Display Chart.js chart in Node.js
- How to access or get value of specific graph on chart plot by click event?
- Chart.js chart does not display when inside an ngIf.
- Beginner using chart.js: having trouble display state full of data into a column chart using variables
- Display Time In Y Axis - Bubble Chart
- How to plot a line chart in ChartJS?
- ChartJS horizontal chart display legend on each bar
- ChartJS : How to display two "y axis" scales on a chart
More Query from same tag
- Chart.js using json data
- Display image on bar chart.js along with label (chartjs-plugin-datalabels)
- How to customize Data Labels of area chart on ChartJS?
- Chart.js plotting two json datasets on a line chart
- How to handle epic long text at y-axis for angular-chart.js?
- convert javascript to dart
- How to show Y axis ticks for every point in the graph
- Reloading ChartJs Image
- How to implement concentric doughnut charts in polymer 1.0 using Chart.js?
- Error in created hook (Promise/async): "TypeError: Cannot read property 'position' of undefined"
- Chart.js positive/negative values fill with out twist
- How to use same data / labels on two y axes in Chart.js
- Add horizontal Line to my chart.js Barchart
- How to set static labels for ng2-charts bar charts?
- Chart.js chart appears and disappears on form submit
- I'm getting the error "TypeError: Cannot read property 'extend' of undefined" when trying to import chartjs-plugin-datalabels
- how to display labels at top of charts(chart.js)
- Chart.js with dual axis incorrect starting points (if negative values)
- Pass numeric matrix of rgb color values to chartJSRadar() in R
- Adding a label to a doughnut chart in Chart.js shows all values in each chart
- chart.js: issue with concatening two line charts
- Remove radar chart labels in chart.js
- Chart.js: evenly distribute ticks when using maxTicksLimit
- Angular-Chart.js - Tooltip not working with 0 values
- Exponential decrease
- How implement Chart.js in Angular 2?
- chart.js line chart update once every 5 seconds?
- How to highlight a section of a stack in all bars in a stacked barchart in chartjs
- How to access custom property in dataset object in Bar Chart in React ChartJS 2?
- Execute SQL prepared statement in AJAX