Changing Color on Line Charts

3,802 views
Skip to first unread message

plumwd

unread,
Sep 16, 2010, 11:41:27 AM9/16/10
to Flot graphs
Hi guys,

I have a flot chart implementation on a new application I'm
developing.

I'm having an issue changing the line color. I specify color as
indicated in the api but the color still defaults to whatever is the
flot default color.

Here's a copy of my code.

function getData(callback) {
jQuery.get('<%= Url.Action("FetchData", "PowerMonitoring",
new {id = Model.PowerSourceId}) %>', function (data) {
var jsonData = JSON.parse(data);
callback(jsonData);
});
}

$(function () {
var options = {
lines: { show: true },
color: "#FF0000",
points: { show: false },
yaxis: { min: 0 },
xaxis: {
mode: "time",
twelveHourClock: true
}
};
var placeholder = $("#placeholder");
var series = [];

function fetchData() {

getData(function (data) {
series.push([(new Date(data.timestamp)).getTime(),
data.value]);
$.plot(placeholder, [series], options);
});

if (series.length > 60) {
series.splice(0, 1);
setTimeout(fetchData, 1000);
}
else {
setTimeout(fetchData, 1000);
}
}

setTimeout(fetchData, 1000);
});

George Roberts

unread,
Sep 16, 2010, 1:52:59 PM9/16/10
to flot-...@googlegroups.com
Someone just answered this question I think yesterday? The day before?
Search the archives. Basically put series colors in the series part of the
options. You put your color in the overall options.

- George Roberts
http://gr5.org

--------------------------------------------------
From: "plumwd" <ehi...@oriones.com>
Sent: Thursday, September 16, 2010 11:41 AM
To: "Flot graphs" <flot-...@googlegroups.com>
Subject: Changing Color on Line Charts

ericg

unread,
Oct 18, 2010, 6:23:51 PM10/18/10
to Flot graphs
FYI - An example of line coloring can be found in the annotation.html
example.


On Sep 16, 10:52 am, "George Roberts" <gr-googlegrp...@spamarrest.com>
wrote:
> Someone just answered this question I think yesterday?  The day before?
> Search the archives.  Basically put series colors in the series part of the
> options.  You put yourcolorin the overall options.
>
> - George Robertshttp://gr5.org
>
> --------------------------------------------------
> From: "plumwd" <ehi...@oriones.com>
> Sent: Thursday, September 16, 2010 11:41 AM
> To: "Flot graphs" <flot-...@googlegroups.com>
> Subject: ChangingColoronLineCharts
>
>
>
> > Hi guys,
>
> > I have a flot chart implementation on a new application I'm
> > developing.
>
> > I'm having an issue changing thelinecolor.  I specifycoloras
> > indicated in the api but thecolorstill defaults to whatever is the
> >    });- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages