Closed shibanovp closed 8 years ago
Hello @paul-shibanov,
The option presets AUTOSCALEAXIS
, FIXEDSCALEAXIS
, etc. are not supported. Instead, the proper way to use these presets is to just manually include the options they set. The actual options for each can be found in the Chartist docs (https://gionkunz.github.io/chartist-js/api-documentation.html). Depending on which you chose, there are only 2-5 options to set.
Best regards, Alex
@alexgig I've been trying to use your advice and can't make it work. Thing is you have no ability to set projection to axis with options object. You must have Chartist to do that.
Also you can't set any interpolation with options object because you have to use Chartist API in them.
I have an idea how to solve this without breaking change https://github.com/panosoft/node-chartist/compare/master...paul-shibanov:feature/support-chartist-options?expand=1 Valid:
const co = require('co');
const generate = require('node-chartist');
co(function * () {
const options = {width: 400, height: 200};
const data = {
labels: ['a','b','c','d','e'],
series: [
[1, 2, 3, 4, 5],
[3, 4, 5, 6, 7]
]
};
const bar = yield generate('bar', options, data); //=> chart HTML
})
New approach with Chartist properties:
const co = require('co');
const generate = require('node-chartist');
co(function *() {
const bar = yield generate('bar',
(Chartist) => ({
showLine: false,
axisX: {
type: Chartist.AutoScaleAxis
},
axisY: {
type: Chartist.FixedScaleAxis
},
}),
(Chartist) => ({
series: {
'series-1': {
lineSmooth: Chartist.Interpolation.step()
}
}
}));
});
If this looks good can you reopen this PR to allow me create some tests and update the docs?
Hey @paul-shibanov,
Sorry for the delayed response. This pr can't be reopened for some reason (github is saying the branch got force pushed or something). That aside, I think it'd be good to explore ways to allow things like Chartist.Interpolation.step()
to be used in options as you illustrated.
I am going to open an issue to track the work. I hope to get some time to work on it this week.
Thanks for raising the issue.
Best regards, Alex
@alexgig Great! Please try again, I removed force push.
@alexgig In case you missed previous notification. I have some time to complete the PR.
Hey @paul-shibanov,
Sorry I didn't get to this before the holidays. I have an idea on how I'd like to implement this and should be able to get it done this week. You can follow issue #12 to stay updated on progress.
Best, Alex
Hey @paul-shibanov,
+ node-chartist@1.0.0
supports this feature. Happy charting!
Best, Alex
@alexgig Chartist have some settings that should be set as a property e.g Chartist cannot be required https://github.com/gionkunz/chartist-js/issues/780
Please help, how it can be properly done? I'm started with
lib/chart.js
with idea that it can be used likeIs this approach the best? Should it be expanded to
lib/index.js
?