Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to reload chart without whole page? #802

Open
maulistic opened this issue Apr 27, 2021 · 1 comment
Open

How to reload chart without whole page? #802

maulistic opened this issue Apr 27, 2021 · 1 comment

Comments

@maulistic
Copy link

maulistic commented Apr 27, 2021

Hi. May i get some help? why it still doesn't work? thanks for help.

my code:

<style>
</style>
<script src="/scripts/snippet-javascript-console.min.js?v=1"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/morris.js/0.5.1/morris.min.js"></script>
Refresh Morris <script type="text/javascript"> var morrisLine; initMorris(); //getMorris(); getMorrisOffline();

function initMorris() {
morrisLine = Morris.Line({
element: 'samplechart',
xkey: 'period',
ykeys: ['a', 'b'],
labels: ['YES', 'NO'],
xLabelAngle: 60,
parseTime: false,
resize: true,
lineColors: ['#32c5d2', '#c03e26']
});
}

function setMorris(data) {
morrisLine.setData(data);
}

function getMorris() {
$.get('@Url.Action("GetData")', function (result) {
setMorris(result);
});
}

function getMorrisOffline() {
var lineData = [
{ period: '2006', a: 100, b: 90 },
{ period: '2007', a: 75, b: 65 },
{ period: '2008', a: 50, b: 40 },
{ period: '2009', a: 75, b: 65 },
{ period: '2010', a: 50, b: 40 },
{ period: '2011', a: 75, b: 65 },
{ period: '2012', a: 100, b: 40 }
];
setMorris(lineData);
}
</script>

index.txt

@Greg-J
Copy link

Greg-J commented Aug 26, 2021

Did you look at the documentation? http://morrisjs.github.io/morris.js/lines.html

Specifically at the top of the page:

Note 2: if you need to update the plot, use the setData method on the object that Morris.Line returns. There's a setData example in the GitHub repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants