Comments (14)
is it sort of like this ?
if it is, you can use that example as a basis for adding multiple series that use the same scale
from go-chart.
so, i've looked at N-axis charting before, there are a couple of key considerations;
- what incremental value would that add visually?
- where would the other axes live? would we do away with the single left right placement and have a stack of axes to the left and right?
i tried implementing this over a weekend a while ago and it got away from me very fast, mostly because we have to adjust the canvas to fit the various elements on the chart and each new axis introduced complexity around what the final chart canvas box would look like.
i'm happy to take another stab but what i hope this helps with is to explain why it isn't a trivial refactor. going to keep this ticket open for now and see if i can figure out a lightweight way of doing this
from go-chart.
This might call for a new type of chart as the current N-axis charting assumes we need to scale everything so they all have their own y-axis we can compare.
Consider the following use case where there is a single, universal x & y axis (of the highest series range) which all other lines fit into.
https://www.google.com/trends/explore?q=php,perl,ruby,python
My current use case is charting transformations on data so I can compare the results of multiple algorithms (which all have results within the same general range).
from go-chart.
So the chart current does what is in that link; if you have multiple series it will do a min max across the series and scale each appropriately. What it does not do is draw separate scales, such that each line displays its full min max across the full chart canvas.
We only typically draw another axis if there are series that either use totally different units, or are on a totally different scale (orders of magnitude different).
To see an example like the above, check out: https://github.com/wcharczuk/go-chart/blob/master/_examples/twopoint/main.go
from go-chart.
What it does not do is draw separate scales, such that each line displays its full min max across the full chart canvas.
Are you sure? It seems to be drawing separate scales as the Y-axis on one side is thousands based while the right side (first y-axis) is hundreds based; but both lines consume the whole chart area.
from go-chart.
ok, sorry should have been more specific, it can, optionally, draw (2) total scales and mush them together onto the same canvas, in the case of assigning a series to the secondary y axis which is drawn on the left. if the series are roughly comparable, you can skip assigning to a secondary series and just draw them all on the same scale.
from go-chart.
what might be helpful for me; what are you trying to do in that graph? what is your desired behavior? what isn't working?
from go-chart.
I borrowed the example image from my other work.
My current use case is charting transformations on data so I can compare the results of multiple algorithms (which all have results within the same general range).
It's timeseries data (not stock market) which need different types of normalization, peak detection, etc.. which I would like to draw onto a chart (3-6 lines) to help comprehend the results better.
The google trends example is the easiest comparison I can make to needing multiple data points charted across the same X, Y graph.
from go-chart.
Ah perfect, multiple series is not a problem after all.
func drawChart(res http.ResponseWriter, req *http.Request) {
var s []chart.Series
for i := 0; i < 5; i++ {
var xvalues, yvalues float64
for i := 1; i < 12; i++ {
xvalues = append(xvalues, float64(i))
yvalues = append(yvalues, rand.NormFloat64())
}
s = append(s, chart.ContinuousSeries{
Name: "Prod Request Timings",
Style: chart.Style{
Show: true,
StrokeColor: chart.ColorAlternateBlue,
FillColor: chart.ColorAlternateBlue.WithAlpha(64),
},
XValues: xvalues,
YValues: yvalues,
})
}
graph := chart.Chart{
Width: 1280,
Height: 720,
Background: chart.Style{
Padding: chart.Box{
Top: 50,
},
},
YAxis: chart.YAxis{
Style: chart.StyleShow(),
TickStyle: chart.Style{
TextRotationDegrees: 45.0,
},
},
XAxis: chart.XAxis{
Style: chart.Style{
Show: true,
},
GridMajorStyle: chart.Style{
Show: true,
StrokeColor: chart.ColorAlternateGray,
StrokeWidth: 1.0,
},
},
Series: s,
}
res.Header().Set("Content-Type", "image/png")
graph.Render(chart.PNG, res)
}
from go-chart.
from go-chart.
yeah negative value handling could really be improved. you could also consider using different fill colors for those series, but i'm glad that worked for what you wanted!
from go-chart.
That was just a demo of multiple series. I thought I would post it (and the sample) for others. I won't be using negative values, the same color, or much of any of that.
You might want to mention that multiple series isn't a problem when you use a []chart.Series{...}
on the root graph
object instead of the chart.(X/Y)Axis{}
structs.
from go-chart.
Not sure I am following what the suggestion is here. I would love to use N-Axis too. At the moment as far as I understand the recommendation is to use 1 or 2 axis and scale/shift all your y-values of the 2, 3, 4 etc series to fit in a reasonable range near 1?
from go-chart.
Basically, just create a slice of var s []chart.Series
and fill it with as many series as you want (still only 2-axis though). Then feed it to the graph.
graph := chart.Chart{
Width: 1280,
...
Series: s,
}
from go-chart.
Related Issues (20)
- Can you draw a radar map??
- Syntax error in _examples directory
- Plot image with interactive interface
- Barchart XAxis Stroke inside bars
- help...... how to show each value for bar chart? HOT 2
- Pie does not return image with value 0 input
- Unable to generate graph
- It's possible to reduce number of labels on X Axis? HOT 3
- How to reorder bar charts? HOT 3
- How to draw lines on the top of bars?
- Single element donut charts renders as an empty canvas HOT 1
- How to show series name like this? HOT 1
- Double bar graphs HOT 1
- Negative and positive values in a barchart HOT 3
- Is it possible to create a new tag targeting the latest commit? HOT 1
- CVE-2022-41727 golang.org/x/image HOT 1
- customize the stacked_bar's heigth
- [QUESTION] - Possibility to render chart in xml to png
- Request: bottom legend
- Flat series can't be rendered (CPU spinning) HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-chart.