Chart.js - Draw horizontal line on horizontal bar chartCan't get bar chart colors in Chart js working in React JsHorizontal bar chart in chart.jsRemove the label and show only value in tooltips of a bar chartAdding titles to a dual axis line and bar chart using Chart.jsChartjs.org Chart only displaying in one pageDynamically update value for horizontal line in annotation plugin for Chart.js in Angular 5chartjs-plugins-datalables hidden when window is resized?chart.js 2 - Is it possible to format tick labels with HTML?Chart.js - How to offset bars from ZeroLineHow to change bar color on a angular-chart and chart js bar graph with multiple datasets?
Can I make popcorn with any corn?
What do three bars across the stem of a note mean?
Can divisibility rules for digits be generalized to sum of digits
Dragon forelimb placement
The use of multiple foreign keys on same column in SQL Server
Show that if two triangles built on parallel lines, with equal bases have the same perimeter only if they are congruent.
Today is the Center
Why does Kotter return in Welcome Back Kotter?
Why can't I see bouncing of a switch on an oscilloscope?
Test whether all array elements are factors of a number
Smoothness of finite-dimensional functional calculus
Which models of the Boeing 737 are still in production?
Why are 150k or 200k jobs considered good when there are 300k+ births a month?
Can I ask the recruiters in my resume to put the reason why I am rejected?
TGV timetables / schedules?
What is the offset in a seaplane's hull?
Why "Having chlorophyll without photosynthesis is actually very dangerous" and "like living with a bomb"?
What does it mean to describe someone as a butt steak?
What would happen to a modern skyscraper if it rains micro blackholes?
Collect Fourier series terms
"You are your self first supporter", a more proper way to say it
Pattern match does not work in bash script
Have astronauts in space suits ever taken selfies? If so, how?
How old can references or sources in a thesis be?
Chart.js - Draw horizontal line on horizontal bar chart
Can't get bar chart colors in Chart js working in React JsHorizontal bar chart in chart.jsRemove the label and show only value in tooltips of a bar chartAdding titles to a dual axis line and bar chart using Chart.jsChartjs.org Chart only displaying in one pageDynamically update value for horizontal line in annotation plugin for Chart.js in Angular 5chartjs-plugins-datalables hidden when window is resized?chart.js 2 - Is it possible to format tick labels with HTML?Chart.js - How to offset bars from ZeroLineHow to change bar color on a angular-chart and chart js bar graph with multiple datasets?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I'm trying to achieve the following chart but i am not able to build it.

I was trying with this code (using https://github.com/chartjs/chartjs-plugin-annotation) but i think the solution is not perfect. The value of line "Días meta" needs to be configurable, so the line must be re-drawn as its value changes and the horizontal bar's dataset also changes.
The code:
<script>
var color = Chart.helpers.color;
var horizontalBarChartData =
//labels: ['7', '6', '5', '4', '3', '2', '0'],
labels: ['5', '3', '2', '1'],
datasets: [
label: 'QTA de bultos',
backgroundColor: color('#91B643').alpha(0.5).rgbString(),
borderColor: '#91B643',
borderWidth: 1,
data: [
2,
7,
4,
11
]
]
;
$(document).ready(function ()
var ctx = document.getElementById('myChart').getContext('2d');
window.myHorizontalBar = new Chart(ctx,
type: 'horizontalBar',
data: horizontalBarChartData,
options:
// Elements options apply to all of the options unless overridden in a dataset
// In this case, we are setting the border of each horizontal bar to be 2px wide
elements:
rectangle:
borderWidth: 2,
,
responsive: true,
legend:
position: 'top',
,
title:
display: true,
text: 'Chart.js Horizontal Bar Chart'
,
hover:
animationDuration: 0
,
animation:
duration: 1,
onComplete: function ()
var chartInstance = this.chart,
ctx = chartInstance.ctx;
ctx.font = Chart.helpers.fontString(Chart.defaults.global.defaultFontSize, Chart.defaults.global.defaultFontStyle, Chart.defaults.global.defaultFontFamily);
ctx.textAlign = 'left';
ctx.textBaseline = 'center';
this.data.datasets.forEach(function (dataset, i)
var meta = chartInstance.controller.getDatasetMeta(i);
meta.data.forEach(function (bar, index)
var data = dataset.data[index];
ctx.fillStyle = "#000";
ctx.fillText(data, bar._model.x + 5, bar._model.y);
);
);
,
scales:
yAxes: [
scaleLabel:
display: true,
labelString: 'Días en Almacén'
,
gridLines:
display: false
],
xAxes: [
gridLines:
display: true
,
ticks:
beginAtZero: true
]
,
annotation:
annotations: [
type: 'line',
mode: 'horizontal',
scaleID: 'x-axis-0',
value: 1,
borderColor: 'rgb(75, 192, 192)',
borderWidth: 4,
label:
enabled: true,
content: 'Días meta: 999'
]
);
);
</script>
Example - With original dataset
Example - With change only one value of dataset
Any help will be appreciated, thanks =)
chart.js
add a comment |
I'm trying to achieve the following chart but i am not able to build it.

I was trying with this code (using https://github.com/chartjs/chartjs-plugin-annotation) but i think the solution is not perfect. The value of line "Días meta" needs to be configurable, so the line must be re-drawn as its value changes and the horizontal bar's dataset also changes.
The code:
<script>
var color = Chart.helpers.color;
var horizontalBarChartData =
//labels: ['7', '6', '5', '4', '3', '2', '0'],
labels: ['5', '3', '2', '1'],
datasets: [
label: 'QTA de bultos',
backgroundColor: color('#91B643').alpha(0.5).rgbString(),
borderColor: '#91B643',
borderWidth: 1,
data: [
2,
7,
4,
11
]
]
;
$(document).ready(function ()
var ctx = document.getElementById('myChart').getContext('2d');
window.myHorizontalBar = new Chart(ctx,
type: 'horizontalBar',
data: horizontalBarChartData,
options:
// Elements options apply to all of the options unless overridden in a dataset
// In this case, we are setting the border of each horizontal bar to be 2px wide
elements:
rectangle:
borderWidth: 2,
,
responsive: true,
legend:
position: 'top',
,
title:
display: true,
text: 'Chart.js Horizontal Bar Chart'
,
hover:
animationDuration: 0
,
animation:
duration: 1,
onComplete: function ()
var chartInstance = this.chart,
ctx = chartInstance.ctx;
ctx.font = Chart.helpers.fontString(Chart.defaults.global.defaultFontSize, Chart.defaults.global.defaultFontStyle, Chart.defaults.global.defaultFontFamily);
ctx.textAlign = 'left';
ctx.textBaseline = 'center';
this.data.datasets.forEach(function (dataset, i)
var meta = chartInstance.controller.getDatasetMeta(i);
meta.data.forEach(function (bar, index)
var data = dataset.data[index];
ctx.fillStyle = "#000";
ctx.fillText(data, bar._model.x + 5, bar._model.y);
);
);
,
scales:
yAxes: [
scaleLabel:
display: true,
labelString: 'Días en Almacén'
,
gridLines:
display: false
],
xAxes: [
gridLines:
display: true
,
ticks:
beginAtZero: true
]
,
annotation:
annotations: [
type: 'line',
mode: 'horizontal',
scaleID: 'x-axis-0',
value: 1,
borderColor: 'rgb(75, 192, 192)',
borderWidth: 4,
label:
enabled: true,
content: 'Días meta: 999'
]
);
);
</script>
Example - With original dataset
Example - With change only one value of dataset
Any help will be appreciated, thanks =)
chart.js
add a comment |
I'm trying to achieve the following chart but i am not able to build it.

I was trying with this code (using https://github.com/chartjs/chartjs-plugin-annotation) but i think the solution is not perfect. The value of line "Días meta" needs to be configurable, so the line must be re-drawn as its value changes and the horizontal bar's dataset also changes.
The code:
<script>
var color = Chart.helpers.color;
var horizontalBarChartData =
//labels: ['7', '6', '5', '4', '3', '2', '0'],
labels: ['5', '3', '2', '1'],
datasets: [
label: 'QTA de bultos',
backgroundColor: color('#91B643').alpha(0.5).rgbString(),
borderColor: '#91B643',
borderWidth: 1,
data: [
2,
7,
4,
11
]
]
;
$(document).ready(function ()
var ctx = document.getElementById('myChart').getContext('2d');
window.myHorizontalBar = new Chart(ctx,
type: 'horizontalBar',
data: horizontalBarChartData,
options:
// Elements options apply to all of the options unless overridden in a dataset
// In this case, we are setting the border of each horizontal bar to be 2px wide
elements:
rectangle:
borderWidth: 2,
,
responsive: true,
legend:
position: 'top',
,
title:
display: true,
text: 'Chart.js Horizontal Bar Chart'
,
hover:
animationDuration: 0
,
animation:
duration: 1,
onComplete: function ()
var chartInstance = this.chart,
ctx = chartInstance.ctx;
ctx.font = Chart.helpers.fontString(Chart.defaults.global.defaultFontSize, Chart.defaults.global.defaultFontStyle, Chart.defaults.global.defaultFontFamily);
ctx.textAlign = 'left';
ctx.textBaseline = 'center';
this.data.datasets.forEach(function (dataset, i)
var meta = chartInstance.controller.getDatasetMeta(i);
meta.data.forEach(function (bar, index)
var data = dataset.data[index];
ctx.fillStyle = "#000";
ctx.fillText(data, bar._model.x + 5, bar._model.y);
);
);
,
scales:
yAxes: [
scaleLabel:
display: true,
labelString: 'Días en Almacén'
,
gridLines:
display: false
],
xAxes: [
gridLines:
display: true
,
ticks:
beginAtZero: true
]
,
annotation:
annotations: [
type: 'line',
mode: 'horizontal',
scaleID: 'x-axis-0',
value: 1,
borderColor: 'rgb(75, 192, 192)',
borderWidth: 4,
label:
enabled: true,
content: 'Días meta: 999'
]
);
);
</script>
Example - With original dataset
Example - With change only one value of dataset
Any help will be appreciated, thanks =)
chart.js
I'm trying to achieve the following chart but i am not able to build it.

I was trying with this code (using https://github.com/chartjs/chartjs-plugin-annotation) but i think the solution is not perfect. The value of line "Días meta" needs to be configurable, so the line must be re-drawn as its value changes and the horizontal bar's dataset also changes.
The code:
<script>
var color = Chart.helpers.color;
var horizontalBarChartData =
//labels: ['7', '6', '5', '4', '3', '2', '0'],
labels: ['5', '3', '2', '1'],
datasets: [
label: 'QTA de bultos',
backgroundColor: color('#91B643').alpha(0.5).rgbString(),
borderColor: '#91B643',
borderWidth: 1,
data: [
2,
7,
4,
11
]
]
;
$(document).ready(function ()
var ctx = document.getElementById('myChart').getContext('2d');
window.myHorizontalBar = new Chart(ctx,
type: 'horizontalBar',
data: horizontalBarChartData,
options:
// Elements options apply to all of the options unless overridden in a dataset
// In this case, we are setting the border of each horizontal bar to be 2px wide
elements:
rectangle:
borderWidth: 2,
,
responsive: true,
legend:
position: 'top',
,
title:
display: true,
text: 'Chart.js Horizontal Bar Chart'
,
hover:
animationDuration: 0
,
animation:
duration: 1,
onComplete: function ()
var chartInstance = this.chart,
ctx = chartInstance.ctx;
ctx.font = Chart.helpers.fontString(Chart.defaults.global.defaultFontSize, Chart.defaults.global.defaultFontStyle, Chart.defaults.global.defaultFontFamily);
ctx.textAlign = 'left';
ctx.textBaseline = 'center';
this.data.datasets.forEach(function (dataset, i)
var meta = chartInstance.controller.getDatasetMeta(i);
meta.data.forEach(function (bar, index)
var data = dataset.data[index];
ctx.fillStyle = "#000";
ctx.fillText(data, bar._model.x + 5, bar._model.y);
);
);
,
scales:
yAxes: [
scaleLabel:
display: true,
labelString: 'Días en Almacén'
,
gridLines:
display: false
],
xAxes: [
gridLines:
display: true
,
ticks:
beginAtZero: true
]
,
annotation:
annotations: [
type: 'line',
mode: 'horizontal',
scaleID: 'x-axis-0',
value: 1,
borderColor: 'rgb(75, 192, 192)',
borderWidth: 4,
label:
enabled: true,
content: 'Días meta: 999'
]
);
);
</script>
Example - With original dataset
Example - With change only one value of dataset
Any help will be appreciated, thanks =)
chart.js
chart.js
asked Mar 21 at 23:22
Daniel Carpio ContrerasDaniel Carpio Contreras
32629
32629
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55290673%2fchart-js-draw-horizontal-line-on-horizontal-bar-chart%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55290673%2fchart-js-draw-horizontal-line-on-horizontal-bar-chart%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown