浮动条形图刻度线不显示

发布于 2024-12-02 16:49:20 字数 582 浏览 0 评论 0原文

我的数据:

var data5 = [
    { label: "my cat",  data: [[1,10], [4,20], [7,30]], color: 'rgb(85, 96, 42)'},
    { label: "my job",  data: [[2,30], [5,20], [8,30]], color: '#42215F'}
];

我的选项:

var type = {};
type[charttype] = {show: true};
type["xaxis"] = {ticks: [[1,"foo"], [2,"bar"], [4,"cat"], [5,"woo"], [7,"cookie"], [8,"yay"]]};

var chart_options = {};
chart_options["series"] = type;

但是,当我

var plot = $.plot($(div), data5, chart_options);

刻度线仅显示为 1-9,而不是我给出的字符串时。 我做错了什么?

my data:

var data5 = [
    { label: "my cat",  data: [[1,10], [4,20], [7,30]], color: 'rgb(85, 96, 42)'},
    { label: "my job",  data: [[2,30], [5,20], [8,30]], color: '#42215F'}
];

my options:

var type = {};
type[charttype] = {show: true};
type["xaxis"] = {ticks: [[1,"foo"], [2,"bar"], [4,"cat"], [5,"woo"], [7,"cookie"], [8,"yay"]]};

var chart_options = {};
chart_options["series"] = type;

however, when I

var plot = $.plot($(div), data5, chart_options);

The ticks just show up as 1-9, instead of with the strings I've given.
What am I doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情泪▽动烟 2024-12-09 16:49:20

试试这个:

var data5 = [
    { label: "my cat",  data: [[1,10], [4,20], [7,30]], color: 'rgb(85, 96, 42)'},
    { label: "my job",  data: [[2,30], [5,20], [8,30]], color: '#42215F'}
];

var chart_options = {
    series: {lines:{show: true}},
    xaxis:{ticks: [[1,"foo"], [2,"bar"],  [4,"cat"], [5,"woo"],  [7,"cookie"], [8,"yay"] ]}
};

var plot = $.plot($('div'), data5, chart_options);

Demo

charttype 替换为实际类型(线/点.. )

xaxis 不应位于 series 对象内部,而应位于同一级别。

Try this:

var data5 = [
    { label: "my cat",  data: [[1,10], [4,20], [7,30]], color: 'rgb(85, 96, 42)'},
    { label: "my job",  data: [[2,30], [5,20], [8,30]], color: '#42215F'}
];

var chart_options = {
    series: {lines:{show: true}},
    xaxis:{ticks: [[1,"foo"], [2,"bar"],  [4,"cat"], [5,"woo"],  [7,"cookie"], [8,"yay"] ]}
};

var plot = $.plot($('div'), data5, chart_options);

Demo

charttype is replaced with an actual type (lines/points..)

xaxis should not be inside of series object, instead on the same level.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文