Comments (7)
take a look at the first two examples here: https://leeoniya.github.io/uPlot/demos/multi-bars.html
you can provide disp.fill
and disp.stroke
callbacks to the bars pathbuilder that can do per-bar coloring.
Lines 217 to 234 in e579947
from uplot.
Hi @leeoniya Thanks for the response. I understood the solution you suggested but it does not resolve the complete problem in my case. In this case I can render bar charts of different colour with different labels but I'm not able to select/deselect different colors in the metric legends(same goes for the demo which you have shared). Any solution on this is highly appreciated!
from uplot.
Added some images for your reference @leeoniya :)
when Legend Selected
when legend is not selected
from uplot.
uPlot's legend is series-based.
since there is only one series here, what you're looking for is a value-based legend. so probably you can make your own legend that would act as a data/value filter when clicked and use u.setData(filteredData)
to update the plot with the "off" values removed. so, for example if you wanted to disable "Wed", you can have your custom legend filter out data at index [2].
this is a bit of an unusual requirement, i think. do you have examples of other chart libraries that do this?
for example, Chart.js legend is also series-based: https://www.chartjs.org/docs/latest/charts/bar.html
same with echarts: https://echarts.apache.org/examples/en/index.html#chart-type-bar
same with high charts: https://www.highcharts.com/demo/highcharts/bar-basic
from uplot.
Hi @leeoniya Thanks again for the response. I worked on the solution you suggested, this is working well. :)
from uplot.
Hi @leeoniya Regarding the same issue. Is there any way tooltip may work for similar bar chart. Checked the current tooltip plugin shared in demos. It works with series so there is single text for whole chart, Is there any way I can have a separate tooltip label for each bar?
from uplot.
the tooltip is not part of uPlot, so you can definitely make your own work however you need.
from uplot.
Related Issues (20)
- Tooltip issue #question
- fix mouse interaction performance for 2,000 series HOT 1
- base 2 ranging and ticks without log scale
- Secondary sync demos not working HOT 6
- Ranger selection does not trigger mousemove event. HOT 5
- Click event on chart is 'destroying' existing selection
- Is it possible to create stacked bar charts that are grouped by year ? HOT 2
- what would be an approach to make groups of series? HOT 1
- Can I hide an axis but not the ortho lines? HOT 5
- Solution for adding padding within the canvas itself? HOT 2
- Setting Legend Markers using Paths HOT 1
- Seeking guidance on creating a dynamic chart with the following features HOT 2
- how do set bar with in uplot HOT 1
- Best practice to avoid clipped axis ticks' labels HOT 2
- lineInterpolation not working HOT 1
- Set data array read position in options to enable circular buffered data HOT 1
- How set equal axis aspect ratio HOT 2
- Firefox 125 renders points on simple lines HOT 2
- Preserve chart / canvas with paths HOT 1
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 uplot.